need to synchronize two figures in matlab gui

I want to synchronise two figures in separate windows. The example code is given below. Please can someone write a code for eme as I have just started using MATLAB GUI.
im = imread (ImageA.jpg)
figure (1);
imagesc(im)
im1 =in2bw(im);
figure (2);
imagesc(im1)

4 Comments

What does "synchronize" mean? What is the problem with the shown code?

So now it's two windows? Are you going to delete this question as well after I mention you should look into addlistener?

By synchronize, I mean when I zoom in or zom out figure 1 , the figure 2 zoom itself to the same point.
https://au.mathworks.com/matlabcentral/answers/396424-need-to-synchronize-two-figures-in-matlab-gui#comment_559387 I deleted that question as I thought it was not clear enough. Can you please write a code for this aS I am a beginner

Sign in to comment.

 Accepted Answer

linkaxes()

10 Comments

linkaxes is to move axes in a figure only. is it rite?
my images are opening up in different figure windows
Works fine when I try with different figures.
Can you please write a code. I will be very thankful. I have already tried using linkaxis but it isnt working.
fig1 = figure(1); ax1 = axes(fig1); fig2 = figure(2); ax2 = axes(fig2);
plot(ax1,rand(1,20)); plot(ax2,rand(1,20))
linkaxes([ax1, ax2], 'xy')
thank you so much. This is such a nice effort to help beginners like us to encourage and learn
Do I need to call this function while using matkab GUI? My image is not showing up after doing this code ,its showing some graph

This is my actual code in which I am getting 2 value (MBT and MAT) and paasing it to the function that process image and count blobs.

imGS = im2double(rgb2gray(im));
  MBT = str2double(get(handles.edtMBT,'string'));
  MAT = str2double(get(handles.edtMAT,'string'));
  figure(1)
  imagesc(imGS)
  colormap(gray)
  axis equal tight
  axis off
  [estCentroids,imBW] = CountSheep(imGS, MBT, MAT);
  A = size(estCentroids,1);
  set(handles.text10, 'String',A);
  distThreshold = 10;
  err = CheckCentroids(trueCentroids, estCentroids, distThreshold);
  figure (3)
  imagesc(im);
  axis equal tight
  axis off
  hold on
  plot(trueCentroids(:, 1), trueCentroids(:, 2), 'b*',...
      estCentroids(:, 1), estCentroids(:, 2), 'ro')
    %title(sprintf('MAT = %f, MBT = %f', MAT, MBT));
    legend('True Centroids', 'Estimated Centroids');
    %axis equal tight
    %axis off

Please search Answers using the phrase

   tag:"always parent" 

Sign in to comment.

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Asked:

on 21 Apr 2018

Commented:

on 23 Apr 2018

Community Treasure Hunt

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

Start Hunting!