Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:15:59+00:00 2026-06-11T08:15:59+00:00

I have a GUI with two axes. The first axes has a low-resolution image.

  • 0

I have a GUI with two axes. The first axes has a low-resolution image.

What I would like to do is select an area on the first axes using IMRECT and then display that area as a high-resolution image on the second axes, while continuously updating as I move the IMRECT rectangle around.

The only way I have been able to do this is with a “for loop” with a 0.1 pause in it that just runs for a minute or two while I select and change the ROI with IMRECT, very cumbersome.

My thought was to use a function that ran whenever the mouse moved within the first axes, with the ploting and getPosition commands in that function. However, I’m not sure how to write such a function (triggering on mouse movement within an axes).

Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:16:01+00:00Added an answer on June 11, 2026 at 8:16 am

    In general, you should assign a callback to your imrect. For example:

    x = imrect();
    x.addNewPositionCallback( @(x)(disp('The rect has changed')))
    

    The callback should get additional parameters, such as the image and the second axes by utilizing anonymous functions.


    I wrote a small code snippet that does what you want. You should add boundary checks, since I did not bother. It updates CData instead of running imshow when you move the rectangle, so it is quite smooth.

    GUI

    function Zoomer
        figure();
    
        highResImage = imread('peppers.png');
        lowResImage = imresize(highResImage,0.5);
    
        a1 = subplot(2,1,1);
        a2 = subplot(2,1,2);
    
        imshow(lowResImage,'Parent',a1);
        initialPosition = [10 10 100 100];
        lowResRect = imrect(a1,initialPosition);
    
        lowResRect.addNewPositionCallback( @(pos)Callback(pos,a2,highResImage));
    
        Callback( initialPosition , a2, highResImage);
    end
    
    function Callback(position,axesHandle, highResImage)
        position = position * 2;
        x1 = position(1);
        y1 = position(2);
        x2 = position(1) + position(3);
        y2 = position(2) + position(4);
    
        highResThumbnail = highResImage( round(y1:y2),round(x1:x2),:);
    
        if isempty( get(axesHandle,'Children')) 
            imshow(highResThumbnail,'Parent',axesHandle);   
        else
            imHandle = get(axesHandle,'Children');
            oldSize = size(get(imHandle,'CData'));
            if ~isequal(oldSize, size(highResThumbnail))
                imshow(highResThumbnail,'Parent',axesHandle);
            else
                set( imHandle,'CData', highResThumbnail);
            end     
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a design like this: Object GUI has two objects: object aManager
I have a class which construct a GUI which has two JComboBoxes , comboA
I have a gui that uses card layout as layout manager.this gui has two
I have a GUI application in Python that has two buttons both aligned to
I have a two panel wxPython GUI set up. In my right panel, I
i have two assemblies 1. MyProj.GUI 2. MyProj in MyProj i define an enum
I have two programs: one CLI program, and one GUI. The GUI is a
I have a ThreadManager with two Threads. One for gui-relevant requests and one for
Say I have two classes, and neither of them are GUI components. Class A
I have a GUI app written in C++/CLI which has a load of configurable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.