Massive slow down in mouseclick behaviour in APPDESIGNER compared to GUIDE

3 vues (au cours des 30 derniers jours)
Jason
Jason le 20 Fév 2020
Commenté : Jason le 25 Fév 2020
Hello. I am observing quite a difference in beahviour between GUIDE and appdesigner.
I have an image that I have created a mouseclick callback which once the image has been displaye din an axes component allows the user to click - this then records the click postion on the image and calculates a mean of a small area around this position.
In GUIDE I Do this:
%Ensure x & y are integers (i.e. represent pixels)
x=round(curX); %Cur X is the current mouseclick x position
y=round(curY); %Cur Y is the current mouseclick y position
setappdata(0,'curX',x); %Save for later use
setappdata(0,'curY',y); %Save for later use
hold on
plot(x,y,'r+','MarkerSize',15,'LineWidth',1) %Display on image where user has clicked.
hold off;
refresh
%Get Zoomed in image
IMG =double( getimage(handles.axes1)); %Get image data
delta=100; %Halfwidth of ROI region to get mean on
ROI = IMG(y-delta:y+delta, x-delta:x+delta,:);%Get the ROI
mm=mean2(ROI); %Perfrom the mean
%Displat ROI rectangle and text of mean on the image
hold on
rectangle('Position',[x-delta y-delta 2*delta 2*delta], 'EdgeColor','y','LineWidth',0.5);
text(x,y-delta-45,num2str(mm,'%.1f'),'FontSize',10,'Color','r', 'HorizontalAlignment','center')
hold off
This occurs almost instantly, say <0.25s
When I have tried to do this using APPDESIGNER, the plotting of the point with a marker is quick, however the calculation of the mean of the ROI and drawing of the rectangle with text is very slow. In all it takes about 2s. I cannot figure out wht it takes so much longer.
z=app.UIAxes.CurrentPoint;
x=round(z(1,1)); y=round(z(1,2));
hold(app.UIAxes,'on');
plot(app.UIAxes,x,y,'b*'); drawnow
I=getimage(app.UIAxes);
Intensity=I(y,x); %Intensity of image at point x,y
%Now get mean of square region centred on x,y
delta=100;
ROI = I(y-delta:y+delta, x-delta:x+delta,:);
mn=mean(ROI(:)); %Have also tried mean2(ROI) - but no better
rectangle(app.UIAxes,'Position',[x-delta y-delta 2*delta 2*delta], 'EdgeColor','y','LineWidth',0.5);
text(app.UIAxes,x,y-delta-45,num2str(mn,'%.1f'),'FontSize',12,'Color','r', 'HorizontalAlignment','center');
hold(app.UIAxes,'off');
  10 commentaires
Adam
Adam le 25 Fév 2020
Yeah, draw now can be very slow, depending what is in the figure. I haven't used appdesigner much, but when I did it does seem generally slower than GUIDE, to first launch the UI at least, which is a lot down to drawing it so it doesn't surprise me if this is quicker from a GUIDE GUI.
Jason
Jason le 25 Fév 2020
But the first drawnow seems to be OK

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by