GUI - "entrance effect"

Hello, what's the best way to create in matlab GUI (GUIDE) a "entrance effect". I mean, like you have in power point animation.
I have a certain image, let's say size = [1000 1000]. I'd like to show first (:,1:100) then (:,101:200) and so forth.
If I simply try to imagesc a certain slice of my image, it gets "smeared" all over the axes. How can draw each column of the matrix image at it's right location?
Also, what's the best way create a "smooth entrance left-to-right" effect? I was thinking on working with pause...is there a better approach? You know, something like the entrance speed you have in Power Point...

Answers (1)

Walter Roberson
Walter Roberson on 22 Jan 2016

0 votes

You can pass x and y coordinates of the corners to imagesc(). Please read the documentation about what the coordinates represent as you will probably want to add 1/2 to the "natural" coordinates to use.

6 Comments

Mark Golberg
Mark Golberg on 22 Jan 2016
Edited: Mark Golberg on 22 Jan 2016
Thank you Walter. Couldn't figure out how to use the x,y coordinates for my purpose.
Let's say I have my figure opened. At first it's ALL blank. Now I'd like to "put" on it only a thin slice of my image, let's say (:,1:10). B-U-T, I don't want it to be stretched all over the blank figure. I want to see now the thin slice of the image (columns 1:10), and the rest should be still blank. Then I could use pause(n), and draw the second slice...thus creating the effect of "image entrance", like, sliding in from Left to Right.
Unless, of course, there is some better way to do it...
[nrow, ncol, npane] = size(YourImage);
ax = gca;
set(ax, 'Xlim', [0 ncol], 'YLim', [0, nrow], 'DataAspectRatio', [1 1 1]);
for right_col = 10 : 10 : ncol
image(1/2 + [0 right_col], 1/2 + [0 nrow], YourImage(:,1:right_col,:));
pause(1);
end
if right_col ~= ncol
image(1/2 + [0 ncol], 1/2 + [0 nrow], YourImage);
end
Thank you for the code Walter, but it doesn't do what I want. Again, I'd like to create an effect that is very easily achieved in PowerPoint, when an image SLIDES IN (for example from left to right).
The problem with your code is that when it draws the first 10 columns, this intermediate image (:,1:10), is getting smeared/stretched all over the axis.
I mean, after the first loop iteration I should see that ALL the image is BLANK, except for a thin slice of 10 pixels/columns on the left of it.
Instead, I don't have a BLANK image, but rather those 10 columns are stretched across the entire x-axis.
Do you understand my problem?
That's called a "transition" animation effect in Powerpoint. Do you want the whole axes control to slide in from the right, or do you want the axes to be in one spot (part of the whole screen) and have the image slide into the axes control from the right?
I've found the solution. Simply needed to invert the order. First image... then set(ax, ....)
It draw slice perfectly.
THANK YOU.
I keep forgetting that the axes limits are cleared for new drawing if hold is not on.

Sign in to comment.

Asked:

on 21 Jan 2016

Commented:

on 22 Jan 2016

Community Treasure Hunt

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

Start Hunting!