Hello, So I have a footprint in binary image and I have to divide it into 3 area with the same length but without the fingers. I have to do it using GUI.Is there any way how to do it? If it help, I give the picture about how to divide it above. Thank's a lot.

 채택된 답변

Image Analyst
Image Analyst 2016년 7월 28일

1 개 추천

Just figure out the row numbers, for example
[rows, columns, numberOfColorChannels] = size(binaryImage);
row1 = round(rows/3);
row2 = round(2*rows/2);
topThird = binaryImage(1:row1, :);
middleThird = binaryImage((row1+1):row2, :);
bottomThird = binaryImage((row2+1):end, :);

댓글 수: 13

Varian Adisuryo
Varian Adisuryo 2016년 7월 28일
Thanks a lot for your help again. So we have to know the row numbers first, then if I want to divide into 3 part it means I have to know the row numbers from where the fingers is not include. Is that right?
Or, what if I detect the boundaries of the foot's body first and then divide it into 3 part. is it possible?
The point is I have to divide the body part of the foot into 3 part and calculate each area. would you give me some suggestion the best way?
Image Analyst
Image Analyst 2016년 7월 28일
If you don't want the toes, you can threshold the image then call bwareafilt to get the largest blob. Or you can call bwareaopen() to throw away blobs smaller than a certain size. Then you can call regionprops() on just the remaining main part of the foot to get the bounding box.
Varian Adisuryo
Varian Adisuryo 2016년 7월 28일
okay I will try it, thank you so much for the suggestion.
Varian Adisuryo
Varian Adisuryo 2016년 8월 4일
sir, I have tried your first answer and apply it in my image and it works, the image can divided into 3 parts with the same length. But when I crop the image first and use your code, it doesn't divided into 3 parts. Could you please help me to correct it? or give me suggestion about where I can learn about it?
Image Analyst
Image Analyst 2016년 8월 5일
It has to work. Are you sure you updated the number of rows and columns based on the cropped image instead of using the original, precropped size? Otherwise show your code.
Varian Adisuryo
Varian Adisuryo 2016년 8월 5일
yes sir you are right, after I use the number of rows from the cropped image, it work perfectly. Thank you so much
Varian Adisuryo
Varian Adisuryo 2016년 8월 5일
sir If I may, I want to ask one more question and it related with your previous help. so I have made a threshold image using slider in my GUI and now I want to use "bwareaopen" to hide the toes. My question is, how to connect "bwareaopen" function to the threshold image that based on the slider?
In the function where you are going to call bwareaopen(), make sure it has the handles structure in scope, then do this:
sliderValue = handles.slider1.Value;
% sliderValue = get(handles.slider1, 'Value'); % This is the old way.
if sliderValue < 1
% Don't let go less than 1.
sliderValue = 1;
handles.slider1.Min = 1;
handles.slider1.Value = 1;
end
minAcceptableArea = round(sliderValue);
binaryImage = bwareaopen(binaryImage, minAcceptableArea);
Replace slider1 with the actual tag name of your slider.
Varian Adisuryo
Varian Adisuryo 2016년 8월 6일
sorry sir I tried and error, I still dont understand. when I replace the minAcceptableArea with the value like 100000 it become error.
If I want to use pushbutton to activate bwareaopen and show the result in the axes2 then where I should place your code?
Do you expect me to know the error without showing me your code and without showing me your error?
You put the code in the callback function for your pushbutton. Like
function pushbutton_click(hObject........
binaryImage = bwareaopen(......
axes(handles.axes2);
imshow(binaryImage);
I truly apologize sir. so this is my current code for "foot body" pushbutton:
if true
a=getappdata(0,'a');
a_gray=rgb2gray(a);
a_bw=im2bw(a_gray, .33);
a_bw2=bwareaopen(a_bw,100000);
axes(handles.axes2);
imshow(a_bw2);
setappdata(0,'filename',a_bw2);
end
Now this is the callback from the slider:
if true
a=getappdata(0,'a');
a_gray=rgb2gray(a);
thresholdValue = uint8(get(handles.slider1, 'Value'));
sliderValue = get(handles.slider1, 'Value');
a_bw=a_gray > thresholdValue;
axes(handles.axes2);
imshow(a_bw)
end
then I want to replace the threshold level in im2bw using the value from the slider and use the bwareaopen to hide the toes. Please show me the way sir. Thank you so much
Make sure your slider goes from 0 to 255, then get its value and don't use im2bw, just threshold it.
In the slider callback:
sliderValue = get(handles.slider1, 'Value');
thresholdValue = uint8(sliderValue);
% Now apply the threshold to make a binary image.
a_bw = a_gray > thresholdValue;
Varian Adisuryo
Varian Adisuryo 2016년 8월 6일
wow it work perfectly. thank you, thank you, thank you so much sir for your help.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by