Menu

3.1.1. Exercise 1: The PixelProcessor - Solution?

2018-07-03
2018-07-04
  • Roland Jungwirth

    I am just starting off with OpenIMAJ and am stuck at 3.1.1. Exercise 1: The PixelProcessor.

    When I try to use the stump that was provided

            input.processInplace(new PixelProcessor<Float[]>() {
                public Float[] processPixel(Float[] pixel) {
    
                    return pixel;
                }
            });
    

    and try to assign the pixel to the HardAssigner, I am always stuck because the pixel is a Float[] but Hardassigner.assign expects a float[]. Any direction as to solving this would help.

     
    • Jonathon Hare

      Jonathon Hare - 2018-07-03

      You've sort of answered the question in the exercise - the problem is that Java doesn't auto-box /unbox arrays, so you have to do the conversion manually, which incurs a potentially significant cost. To do the conversion you can do something like this:

      float[] fp = new float[3];
      for (int i = 0;i < 3;i++){
              fp[i] = pixel[i];
      }
      
       
  • Roland Jungwirth

    Ah, ok - I clearly didn't see the forrest for all the trees ... if I'd only know how to use OpenIMAJ, I'd could make it do that :D

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.