how can I use a threshold value?
이전 댓글 표시
Hello everybody,
I need some help! I have to answer to those questions:
9) Ask the user to enter a thresholding value for the binary mask
10) Given this value, transform the image to a binary image and display the result on the screen [useful tools: read(), im2bw()]
11) Ask the user whether he/she is happy of the result. Yes will be 1 and No will be 0. Put 1 as the default value.
12) Modify these previous lines of code with a loop that only stops when the user is happy of the result. Basically, you can be happy when the EHT is represented as a rectangle with its two ends surrounded by black pixels. If the user is not happy, ask him/her to enter a new thresholding value.
I have already found the following code:
*%question 1
select=uigetfile('video.avi');
%question 2
video=mmreader('video.avi');
%question3
video.NumberOfFrames;
video.Height;
video.Width;
k=video.NumberOfFrames;
for k=100;
mov(1:k)=struct('cdata',[],'colormap',[]);
end;
%question4
%Display the first frame
vidFrame=read(video,k);
%Question 4
%to alert the user that he needs to draw a line on this frame
imshow(vidFrame);
uiwait(msgbox('draw a line on the frame and click on ok to continue', 'Alert'));
%Question5
pos=wait(imline);
l=length(pos);
%question6
m=sqrt((pos(1,2)-pos(1,1)^2)-((pos(2,2)-pos(2,1)^2)));
question 7
prompt= {'enter the real length in micrometers'};
dlg_title='Enter';
num_lines=1;
def={'1'};
answer=inputdlg(prompt,dlg_title,num_lines,def);
%Question8
% Derive the ration pixel/micrometer
r=1/m;
%Question9
%Ask the user to enter a thresholding value for the binary mask
prompt={'enter a thresholding value - value between 0 and 1'};
dlg_title='Input';
num_lines=1;
def={'0.5'};
answer2=inputdlg(prompt,dlg_title,num_lines,def);
%Question 10
%BW = im2bw(vidFrame,answer2);
%imshow(BW);
%level=answer2;
A = str2num('answer2');%to tranform string answer2 in num answer2
level=input('answer2:');%Request user input
BW = im2bw(vidFrame,level);
imshow(BW);
%Question 11
prompt= {'Are you satisfied? 1 for yes or 0 for no'};
dlg_title='Input';
num_lines=1;
def={'1'};
answer3=inputdlg(prompt,dlg_title,num_lines,def);*
Thank you for your help. I'm very lost!!
YF.
댓글 수: 1
Walter Roberson
2013년 12월 21일
It is not clear what you are asking for assistance with.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!