The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 84
Registered: 7/2/10
Crop Image with Fixed Ratio
Posted: Sep 27, 2010 6:02 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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:

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..?

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.