When I crop image Width and Height is decrease

I attach a file code and picture. before use imcrop Width and Height are decrease. it not real value
Please help me

답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 17일
The line
[columns, rows] = find(BW);
should be
[rows, columns] = find(BW);

댓글 수: 9

Adisorn Phanukthong
Adisorn Phanukthong 2017년 2월 17일
편집: Adisorn Phanukthong 2017년 2월 17일
Before use imcrop see im is variable
after use imcrop
I can use clear variable for each time?
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.
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.
I clear all. but output is not match.
"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.
again, when i use function i find height width. finish but when I crop value is change in 2 picture
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.
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?

댓글을 달려면 로그인하십시오.

제품

질문:

2017년 2월 17일

댓글:

2017년 2월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by