Massive slow down in mouseclick behaviour in APPDESIGNER compared to GUIDE

조회 수: 1 (최근 30일)
Jason
Jason 2020년 2월 20일
댓글: Jason 2020년 2월 25일
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
Adam
Adam 2020년 2월 25일
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 2020년 2월 25일
But the first drawnow seems to be OK

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by