user3483746
user3483746

Reputation: 155

How to display the sliced image in an axes in matlab gui?

I have sliced an image using mat2cell() function. And I'm able to display all the sliced images in subplot's together. But I want to display the same in GUI using axes . This is the image I wanted to show in axes .

enter image description here

This is the code I used to slice the image:

K = imresize(J,[128 128]);
C = mat2cell(K,[64,64],[64,64]);

%plotting

figure;
subplot(2,2,1),imshow(C{1});
subplot(2,2,2),imshow(C{2});
subplot(2,2,3),imshow(C{3});
subplot(2,2,4),imshow(C{4});

I don't know how to display these 4 images in a single axes.

Any suggestions?

Thanks in advance!

Upvotes: 0

Views: 157

Answers (1)

il_raffa
il_raffa

Reputation: 5190

It seems not possible to add more than one image on a single axes. I run your code and I've got the impression that your goal is to divide the original image into 4 pieces then to mix them and obtain a new image. If so, what about to take the 4 pieces (the 4 cellarrays) and generate a new matrix and then to display it on a single axes?

a=imread('Jupiter_New_Horizons.jpg');

f=figure('unit','normalized','name','ORIGINAL IMAGE');
% My image is not BW
a(:,:,2:3)=[];
imshow(a)

K = imresize(a,[128 128]);

C = mat2cell(K,[64,64],[64,64]);

f=figure('unit','normalized','name','SPLIT IMAGE');
fp=get(gcf,'position')

subplot(2,2,1),imshow(C{1});
subplot(2,2,2),imshow(C{2});
subplot(2,2,3),imshow(C{3});
subplot(2,2,4),imshow(C{4});

tmp1=C{1,1};
tmp2=C{1,2};
tmp3=C{2,1};
tmp4=C{2,2};

TMP=[tmp1 tmp3;tmp2 tmp4];

f=figure('unit','normalized','name','NEW IMAGE');

ax=axes

imshow(TMP,'parent',ax)
set(gcf,'position',fp)

Original image

enter image description here

Split image

enter image description here

New image

enter image description here

Hope this helps.

Upvotes: 1

Related Questions