When I crop image Width and Height is decrease
Show older comments
I attach a file code and picture. before use imcrop Width and Height are decrease. it not real value
Please help me
Answers (1)
Walter Roberson
on 17 Feb 2017
The line
[columns, rows] = find(BW);
should be
[rows, columns] = find(BW);
9 Comments
Adisorn Phanukthong
on 17 Feb 2017
Edited: Adisorn Phanukthong
on 17 Feb 2017
Adisorn Phanukthong
on 17 Feb 2017
Walter Roberson
on 17 Feb 2017
Sure, go ahead and clear the variable. Doing that will not do anything useful, though, but it will help reassure you that it is not a problem with a variable being left around.
Walter Roberson
on 17 Feb 2017
You show different values for BWAREA, Dispersion, PERI, aspect, cen, columns, height, rows, and width. imcrop() does not write to any of those variables. Your im variable also does not exist before you do the imcrop() so it is not possible for im to have a different value that is being changed by the imcrop(). You are also not saving the value of im anywhere.
So I do not know what you are doing.
The size extracted is going to change between frames. The code finds the narrowest and shortest box that can fit around the white pixels, and that is going to change as the person walks.
If you want to extract the same size of image for all of the frames, you are going to have to alter your code for that purpose, and since the individual images are going to be thinner or taller at different times, you would have to define where in the fixed-sized box you wanted each current image to be put.
Adisorn Phanukthong
on 17 Feb 2017
Walter Roberson
on 17 Feb 2017
"clear all" does even less that is useful than clearing an individual variable.
What exactly are you comparing? As I wrote before,
"Your im variable also does not exist before you do the imcrop() so it is not possible for im to have a different value that is being changed by the imcrop(). You are also not saving the value of im anywhere."
Be specific. Are you putting in a breakpoint at the assignment to im in the routine, and then on the first frame you are taking the output of im and doing something to it? And then you are continuing to the second frame and trying to compare the result of im of the second frame with the result of im of the first frame?
Because if that is what you are doing then you need to expect that the results will be different. As the person walks, their leg moves out and that makes the occupied part of the image wider, changing the width, and when their leg swings back again the occupied part of the image would get narrower again.
Adisorn Phanukthong
on 17 Feb 2017
Walter Roberson
on 17 Feb 2017
Put a breakpoint on the line that calls imcrop. Record the workspace contents. Then give the command
dbstep
at the command line so that imcrop is called. Record the workspace content again. Show us both workspaces.
Image Analyst
on 20 Feb 2017
Adisorn, I have no idea what you're doing but of course if you crop an image to be smaller than it is, of course it will be smaller than before the crop. Also, it two images have different bounding boxes, of course they will be different sizes after cropping. Are you expecting anything different?
Categories
Find more on Image Segmentation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


