How to perform Hot Spot Detection ?

조회 수: 5 (최근 30일)
Syed Muhammad Ali Minhal
Syed Muhammad Ali Minhal 2021년 1월 30일
댓글: Syed Muhammad Ali Minhal 2021년 1월 30일
HI,
what is the equivalent code to be used in App Designer, for the below .m file ?
Thanks
%% Calculate Object Properties Using Pixel Values of Grayscale Image
ti = imread('ti2.jpg');
sc = regionprops('ti2erode.png','ti2rgb.png',{'Centroid','WeightedCentroid'});
figure()
subplot(1,3,1)
imshow(ti)
title('Weighted (red) and Unweighted (blue) Centroids');
hold on
numObj = numel(sc);
for k = 1 : numObj
plot(sc(k).WeightedCentroid(1), sc(k).WeightedCentroid(2), 'r*')
plot(sc(k).Centroid(1), sc(k).Centroid(2), 'bo')
end
hold off

채택된 답변

Mario Malic
Mario Malic 2021년 1월 30일
There's no equivalent code in AppDesigner, if you just open it and do few examples there, you'll figure out what to do. I made some changes to your code, as this is most likely how it'll look like in App Designer, excluding these first two lines.
uiFig = uifigure;
uiAxes = uiaxes('Parent', uiFig)
%% Calculate Object Properties Using Pixel Values of Grayscale Image
ti = imread('ti2.jpg');
sc = regionprops('ti2erode.png','ti2rgb.png',{'Centroid','WeightedCentroid'});
imshow(ti, 'Parent', uiAxes)
title(uiAxes, 'Weighted (red) and Unweighted (blue) Centroids');
hold(uiAxes, 'on')
numObj = numel(sc);
for k = 1 : numObj
plot(uiAxes, sc(k).WeightedCentroid(1), sc(k).WeightedCentroid(2), 'r*')
plot(uiAxes, sc(k).Centroid(1), sc(k).Centroid(2), 'bo')
end
hold off
  댓글 수: 1
Syed Muhammad Ali Minhal
Syed Muhammad Ali Minhal 2021년 1월 30일
Thankyou @Mario Malic, you were right. By the end of the day I was able to figure out what was missing.
Also I was trying to plot in the UIImage instead of the UIAxes
thanks again
Ihsd = imshow(app.ti, 'Parent', app.UIAxes_4, ...
'XData', [1 app.UIAxes_4.Position(3)], ...
'YData', [1 app.UIAxes_4.Position(4)]);
hold(app.UIAxes_4, 'on')
app.alpha = imread("ti2erode.png"); %binary imaage
app.bravo = imread("ti2rgb.png"); % gray scale image
app.sc = regionprops(app.alpha,app.bravo,{'Centroid','WeightedCentroid'});
app.numObj = numel(app.sc);
for k = 1 : app.numObj
plot(app.UIAxes_4, app.sc(k).WeightedCentroid(1), app.sc(k).WeightedCentroid(2), 'r*');
plot(app.UIAxes_4, app.sc(k).Centroid(1), app.sc(k).Centroid(2), 'bo');
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by