Massive slow down in mouseclick behaviour in APPDESIGNER compared to GUIDE
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Adam
el 25 de Feb. de 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.
Respuestas (0)
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!