필터 지우기
필터 지우기

Calculate Area % of either freehand or ellipse ROI

조회 수: 6 (최근 30일)
Victoria
Victoria 2018년 7월 30일
댓글: Image Analyst 2018년 8월 1일
Hello - I'm trying to figure out the Area % of a thresholded ROI. Currently, I have my code set so that the image is thresholded, and then the user manual draws a freehand ROI (still debating if freehand or ellipse ROI is better). I want the code to give me the percent of area that is 'white' in the threshold over the total area in that ROI, but currently when I draw in the ROI, it is filled with 1's. How can I do this so that it is not filled and I can find the % Area? Below is my code. Thank you!
I=imread('Image.tif'); figure,imshow(I); BW = imbinarize(I,0.300); figure,imshow(BW); % Ask user to draw ROI. message = sprintf('Draw ROI on the wanted image.\nDouble click to finish drawing.'); uiwait(msgbox(message)); h=imfreehand;
  댓글 수: 1
Victoria
Victoria 2018년 7월 30일
Update: I have found a way to find area percent with the following code:
percentageBlack=(1-nnz(BW)/numel(BW))*100;
AreaPercent=(100-percentageBlack)
Now I just need a way for this to ONLY calculate in a nonfilled manually selected ROI. Thanks!

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

채택된 답변

Image Analyst
Image Analyst 2018년 7월 30일
Use h to create a mask.
mask = h.createMask;
See attached demo for more details.
  댓글 수: 4
Victoria
Victoria 2018년 8월 1일
T1=table(meanGL, sdGL, percentageBlack, AreaPercent);
head(T1,3)
C = table2cell(T1);
%File Location
path= 'C:\Users\Vicki\Documents\Loyola\MATLAB';
%File Name
xlswrite(fullfile(path,'\try.xlsx'), C, int2str(k));
Image Analyst
Image Analyst 2018년 8월 1일
You can use writetable() to write an Excel workbook without doing the convertion to a cell array.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by