[im-users] using IM image resize function

Antonio Scuri scuri at tecgraf.puc-rio.br
Tue Feb 1 13:50:23 BRST 2005


   I'm sorry the documentation is incomplete. The "dir" parameter is the 
sign of the rotation: "+1" rotates "90" degrees clock wise, "-1" rotates 
"90" degrees counter clock wise (or -90 degrees clock wise).

Best,
Antonio Scuri

At 13:34 1/2/2005, yip tommy wrote:
>I really thank for your help!
>I can now work on RGB image also.
>Also, may I ask you about the rotate function
>imProcessRotate90(). The third argument is the
>direction, I want to ask you that what's the value for
>clockwise and anti-clockwise direction respectively?
>(as the documentation does not clarify)
>
>Thanks.
>
>Best,
>Tommy
>
>
>  --- Antonio Scuri <scuri at tecgraf.puc-rio.br> ¤º®e¡G
> > At 14:20 31/1/2005, yip tommy wrote:
> > >I want to resize my RGB image. I found on the
> > >documentation that I can call imProcessResize() to
> > do
> > >this.
> > >However, after I do the resize, I can get back only
> > >the red channel data. I lost the G, B channels.
> > >Is that the imProcessResize() function can only
> > >perform on gray level images only?
> >
> >    No. The imProcessResize can process any number of
> > channels.
> >
> > >Or I used the wrong
> > >code to do? I used these codes to perform the
> > resize action:
> > >imFile* ifile = imFileOpen("test.jpg", &error);
> > >imImage *image1 = imFileLoadImage(ifile, 0,
> > &error);
> > >imImage *imageResized = imImageClone( image1 );
> > >imageResized->width = image1->width/2;
> > >imageResized->height = image1->height/2;
> > >imProcessResize( image1, imageResized, 1 );
> > >Did I use wrong code?
> >
> >    This code seems not to be the problem. Maybe the
> > problem is in the image
> > output.
> >
> >    But notice that your code is wasting memory,
> > since the imageResized is
> > allocated with 4 times the required memory.
> >
> >    There are also another problem. Although you can
> > manually update width
> > and height to smaller values, you must not forget to
> > update other imImage
> > members that depends on the image size like:
> >
> >    int line_size;      /**< Number of bytes per line
> > in one plane (width *
> > DataTypeSize)    */
> >    int plane_size;     /**< Number of bytes per
> > plane.            (line_size * height)      */
> >    int size;           /**< Number of bytes occupied
> > by the image
> > (plane_size * depth)      */
> >    int count;          /**< Number of pixels
> >              (width *
> > height)          */
> >
> >    Instead of doing that you can simply call:
> >
> > void imImageReshape(imImage* image, int width, int
> > height)
> >
> >    That it will safely change these to the correct
> > values without
> > reallocating memory. Or you can simply do:
> >
> > imImage* imageResized
> > imImageCreate(image1->width/2, image1->height/2,
> > image1->color_space, image1->data_type)
> >
> >    In this particular case that you are reducing the
> > image size I would
> > like to suggest the imProcessReduceBy4 function that
> > will use an optimal
> > approach to reduce the image size by a factor of 4
> > (w/2 and h/2). For other
> > reduce factors you can you the imProcessReduce.
> >
> > Best,
> > scuri
> >
> >
>
>_________________________________________________________
>¥²±þ§Þ¡B¶¼ºq¡B¤p¬P¬P...
>®öº©¹aÁn  ±¡¤ß³sô
>http://us.rd.yahoo.com/evt=22281/*http://ringtone.yahoo.com.hk/




More information about the imtoolkit-users mailing list