App designer - problem with thresholding image

Hi folks,
I have the app attached, in which I am encountering two issues. Firstly, when trying to threshold an image and displaying the thresholded image, it would appear my function calls aren't working as the image displayed is not thresholded. (ResinThreshold function works in live editor, but not when called in app designer). The thresholding function is below.
Thanks
function ResinThreshold(app)
imgGrey = rgb2gray(app.img);
[counts, ~] = imhist(imgGrey, 255);
T = otsuthresh(counts);
BW = imbinarize(imgGrey, T);
BW = bwareaopen(BW, 3000);
BW = imfill(BW, 'holes');
BW = bwperim(BW);
BW = imdilate(BW, ones(5));
BW = imerode(BW, ones(3));
BW = imfill(BW, 'holes');
app.img = app.img.*repmat(uint8(BW),[1 1 3]);
end

댓글 수: 2

DGM
DGM 2021년 4월 11일
I don't see any attached files.
hi @DGM, apologies! I thought I'd attached it...I've ammended the error!

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

 채택된 답변

Image Analyst
Image Analyst 2021년 4월 11일

1 개 추천

You need to display the output image
imshow(app.img);

댓글 수: 5

hi @Image Analyst, this is done in a seperate function call as follows:
function DisplayCrosshairs(app)
I = imshow(app.currentImage, "Parent", app.Image);
app.Image.XLim = [0 I.XData(2)];
app.Image.YLim = [0 I.YData(2)];
app.Width = app.Image.XLim;
app.Height = app.Image.YLim;
quarterHeight = range(app.Height)*0.125;
halfHeight = range(app.Height)*0.5;
threeQuarterHeight = range(app.Height)*0.875;
quarterWidth = range(app.Width)*0.125;
halfWidth = range(app.Width)*0.5;
threeQuarterWidth = range(app.Width)*0.875;
app.positionVector = {quarterWidth quarterHeight;halfWidth quarterHeight;threeQuarterWidth quarterHeight;quarterWidth halfHeight;halfWidth halfHeight;threeQuarterWidth halfHeight;quarterWidth threeQuarterHeight;halfWidth threeQuarterHeight;threeQuarterWidth threeQuarterHeight};
app.checkMatrix = [app.TopLeft.Value app.TopMiddle.Value app.TopRight.Value app.CentreLeft.Value app.CentreMiddle.Value app.CentreRight.Value app.BottomLeft.Value app.BottomMiddle.Value app.BottomRight.Value];
app.numSamplesPerImage = sum(app.checkMatrix, 1:9);
count = 0;
for i = 1 : 9
if app.checkMatrix(i) == 1
ROI(app, app.positionVector{i,:});
count = count + 1;
end
end
if count == 0
msgbox('Please select a quadrant for the crosshair to be displayed in');
end
end
function DisplayImage(app)
app.currentImage = fullfile(app.imageFolder(app.imageNumber).folder, app.imageFolder(app.imageNumber).name);
app.Image.Position = [0 0 app.UIFigure.Position(3:4)];
app.img = imread(app.currentImage);
if app.ThresholdResin.Value == 1
ResinThreshold(app);
end
DisplayCrosshairs(app);
DisplayImageNumbers(app);
end
OK but I didn't see that function called in ResinThreshold(app). Did you? Set a breakpoint in there to see if it ever gets in there.
hi @Image Analyst, I've set a breakpoint and it seems to get there, and it even seems to execute the lines of code but the output just doesn't display. I've attached the mlapp file if that helps.
Image Analyst
Image Analyst 2021년 4월 11일
편집: Image Analyst 2021년 4월 11일
I ran it but didn't know what to do. There are no instructions. You should do what I do. Have a listbox listing all the images, then a series of controls (checkboxes, pushbuttons, etc.) that say "Step 1 : select an image", "Step 2 : Select any options", "Step 3 : Mark Points", "Step 4 : Analyze selected ponts" or whatever. That will essentially guide the user through the various steps without a user manual or training. Otherwise, attach the software manual for it (though I'm not sure I'll read it if it's too lengthy).
hi @Image Analyst, so the app should prompt you to select a folder with images in it on startup. once selected, pushing any of the buttons on the left of the table will move increment the relevant tally and display the next image in sequence.
I haven't listed any instructions as this is a very specific app designed for use by a very few people, and its based entirely on an existing "manual" methodology. Typically, they will go through hundreds of images on the app and tally them up, so it's not feasible to implement a listbox for images.

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

추가 답변 (0개)

제품

릴리스

R2020b

질문:

2021년 4월 10일

댓글:

2021년 4월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by