Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Crop Image with Fixed Ratio
Replies: 5   Last Post: Apr 9, 2013 6:48 AM

 Messages: [ Previous | Next ]
 Nehal Posts: 84 Registered: 7/2/10
Crop Image with Fixed Ratio
Posted: Sep 27, 2010 6:02 AM

I have some multiple dimensional images. For example 150x250, 157x253, ...... ect.
Now I want to resize each images having the row and column ratio fixed.

If I use imresize function, it resizes properly but the shape of the object inside the image is changed/distorted. Because it stretches or squeezes the image. I do not want to change the shape of the object on the image. That is why I want to resize the image with keeping the ratio of the image same.

In my case, the image is a binary image with black background and the object is a white hand. And my required dimension is 50x50.
here is a sample of my image:
http://img20.imageshack.us/img20/8523/sampleimage.png

The steps I need:
1. Matlab will resize the image (for example 150x250) into 30x50 (because of the fixed ratio). Here the largest value between the row and column value will be resized and the other one will be resized having the ratio same.
In my example,
resized row = 30
resized column = 50

2. Now, I want to add 10 black rows on the both side of the resized image. Which means: (10+30+10) = 50 rows (which is my required row size)
and the columns will not be changed.
This is how I can make the object placed in the center of the image.

Can anyone plz help me..?

Date Subject Author
9/27/10 Nehal
9/27/10 ImageAnalyst
9/27/10 Nehal
9/27/10 Nehal
9/27/10 ImageAnalyst
4/9/13 pratibha rane