Page 1 of 1

[6.7.6]problem about GetImageOption() in ReadJPEGImage?

Posted: 2012-07-09T09:39:32-07:00
by zhcn381
hi magick,

I encountered a zoom performance problem. well, here is my code:

Code: Select all

 
Image image; 
Blob srcBlob(some_data, some_len); 
Geometry geometry(some_width, some_height); 
image.read(srcBlob, geometry);
image.zoom(geometry);
I have got some timing test( in the code ), compared to IM6.2.8, the new IM (I' m using 6.7.6) is about 2 times slower. I have already disabled openmp. And finally, with the help of opfofile, I noticed that different coders/jpeg.so is the reason why the read process in the new version is slower(The zoom process is also much slower in the new version. I found the new version spent much CPU cycles in VerticalFilter, while the old version is in HorizontalFilter. The size of the test pic is 740x8427. I'm zooming it into 250x250). Going deeper, I noticed that in the function ReadJPEGImage(), the IM 6.7.6 is using GetImageOption() to get the "jpeg:size" option's value instead of image_info->size, which the old version was using. What's more, I failed to find the SetImageOption() call which would set up the SplayTree. This lead to the NULL result of the call of GetImageOption(), which results in the skip of scaling process of the image(Actually, I don't know why this is needed here. After this process, the pic's output_width and ouput_height is halfen.). I have tried to replace this C calling with the C++ version and the performance downgrade is gone. Could you tell me if I am doing this right ? Thanks.

Re: [6.7.6]problem about GetImageOption() in ReadJPEGImage?

Posted: 2012-07-09T10:00:43-07:00
by magick
Use defineValue() to define the jpeg:size metadata key / value pair before you call the read() method:

Code: Select all

Image img;
  img.defineValue("jpeg","size","250x250");
  img.read("logo.jpg");
  img.zoom("250x250");

Re: [6.7.6]problem about GetImageOption() in ReadJPEGImage?

Posted: 2012-07-09T18:32:23-07:00
by zhcn381
hi, magick

Thanks. I have another question. Using this method need to know the coder type, but before reading the image, how do I know the format of it? I may need to zoom many other types, like png, gif and so on.

Re: [6.7.6]problem about GetImageOption() in ReadJPEGImage?

Posted: 2012-07-09T18:44:56-07:00
by magick
Notice the namespace is JPEG. This define only affects JPEG so you can set it and if the coder is not JPEG, it is simply ignored.

Re: [6.7.6]problem about GetImageOption() in ReadJPEGImage?

Posted: 2012-07-09T19:26:41-07:00
by zhcn381
Thanks for rapid response. One more questions, how can I find all available options that I can set using the method defineValue. I have a special requirement that need to zoom using the minimal dimension. I had tried "^" in the geometry string but it didn't work. so I turned to using another method. That is, get the image's width and height and do the computation of scale_factor by myself, then ignore the aspect ratio. Here is the first problem, I used to read the whole image to get the width and height. Is there a light way to do this? Second, I use Geometry.aspect method to ignore the aspect ratio. This works if I use the image->read(srcBlob, geometry). How should I achieve this now using the method you supply?