ImpixelInfo equivalent for Appdesigner

2 vues (au cours des 30 derniers jours)
Jason
Jason le 18 Nov 2020
Hello, I am trying to create the same effect as impixelinfo in GUIDE in appdesigner. I understand thereis no such function for appdesigner, so I have created the ImageButtonDownCallback.
function ImageButtonDownCallback(app, source, eventargs)
%Delete any previous annoations, graphics on the image
delete(findobj(app.UIAxes, 'Marker', '*')); %Delete previous marker
delete(findobj(app.UIAxes, 'Marker', '.')); %Delete previous marker
delete(findobj(app.UIAxes, 'Type','rectangle')); %Delete previous rectangler
delete(findobj(app.UIAxes, 'Type','text')); %Delete previous text
%Get current mouse position
z=app.UIAxes.CurrentPoint;
x=round(z(1,1)); y=round(z(1,2));
%Show on the image where the point is
hold(app.UIAxes,'on');
plot(app.UIAxes,x,y,'b*');
drawnow;
%Get the image data so can peform basic stats around the selected point
I=double(getimage(app.UIAxes));
%Now get mean of square small region centred on x,y
delta=100;
ROI = I(y-delta:y+delta, x-delta:x+delta);
mn=mean(ROI(:));
mx=max(ROI(:));
%Report out the values (this is a seperate function that reports to a textarea)
ReportMessage1(app,['x=',sprintf('%.0f',x),', y=',sprintf('%.0f',y),': Mean Intensity=',sprintf('%.0f',mn),', Max = ',num2str(mx)]);
%Draw the ROI rectangle on the image to view
rectangle(app.UIAxes,'Position',[x-delta y-delta 2*delta 2*delta], 'EdgeColor','y','LineWidth',1);
%display the basic stats on the image
text(app.UIAxes,x,y-delta-35,num2str(mn,'%.1f'),'FontSize',16,'Color','r', 'HorizontalAlignment','center');drawnow
hold(app.UIAxes,'off');
%Display the ROI on a seperate axis (UIAxes2) for closer inspection
cla(app.UIAxes2,'reset');
%my autoscale function
n=3
[high,low] = Autoscale1(app,ROI,n);
app.myimage=imshow(ROI,[low,high],'Parent',app.UIAxes2); %image creation
end
I call this callback when I first show the image using:
app.myimage=imshow(frame,[low,high],'Parent',parentAxis); drawnow; %image creation
app.myimage.ButtonDownFcn = @app.ImageButtonDownCallback; %create callback. IMPORTANT: You must use app.****
The issue is sometimes this is quite fast (<1s), but other times it seems to take say 10s.
Is there anything I can do mimic impixelinfo better as this takes <200ms everytime

Réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by