How can i subplot list of image in right side GUI? with looping method

im working on color based image retireval..i have a variabel called fileNm containing list pathname of images.
i have successfull to plot them and sorting them for most similiar images to unsimiliar images but in new window called figure 1
i want to display them in right side of GUI like this and sorting them with the most similiar image to unsimiliar images..
this is my currently code.. but i subplot this with no sorting from most similiar image to unsimiliar images at all and i do manual code .. not in looping code..please someone help me..
% Retrieval
k=1;
ThCM=70; %threshold perbandingan citra
for j=1:ukuranbaris
Sum = sum(abs(num(j,:)-databin));
if Sum < ThCM
Dist(k)= Sum;
k=k+1;
fileNm(k) = {raw{j+1,28}};
end
end
Sum
Dist
% fileNm{1}
% fileNm{2}
% fileNm{3}
% fileNm{4}
%sorting for most similiar images to unsimiliar images
[ImShr,Inx] = sort(Dist,'ascend');
pnf = size(Dist')
%program untuk menampilkan citra secara looping pada figure baru
% for k = 2 : pnf
% thisFileName = fileNm{k};
% ImgFile2 = imread(thisFileName);
% %display the image
% axes(handles.axes2) %the current axes should be set to axes1
% imagesc(ImgFile2); %displays the data in array C as an image that uses the full range of colors in the colormap
% %clear axes scale
% subplot(3,3,k),imshow(ImgFile2);
% hold on;
% axis off
% caption = sprintf('File %d of %d : "%s"', k, numel(fileNm), thisFileName)
% title(caption, 'FontSize', 5);
% drawnow;
%
% end
ImShr
Inx
% BIKIN WINDOW BARU
for k = 1 : pnf(1,1)
thisFileName = fileNm{Inx(k)+1};
% figure(1), subplot(3,4,k),imshow(thisFileName);
subplot(3, 4, 2);
imshow(fileNm{2}); %gambar ke 2
subplot(3, 4, 3);
imshow(fileNm{3}); %gambar ke 3
subplot(3, 4, 4);
imshow(fileNm{4}); %gambar ke 4
subplot(3, 4, 6);
imshow(fileNm{5}); %gambar ke 5
subplot(3, 4, 7);
imshow(fileNm{6}); %gambar ke 6
subplot(3, 4, 8);
imshow(fileNm{7}); %gambar ke 7
subplot(3, 4, 10);
imshow(fileNm{8}); %gambar ke 8
subplot(3, 4, 11);
imshow(fileNm{9}); %gambar ke 9
subplot(3, 4, 12);
imshow(fileNm{10}); %gambar ke 10
% caption = sprintf('File %d of %d : "%s"', k, numel(fileNm), thisFileName);
% title(caption, 'FontSize', 5);
%hold on
drawnow;
end
pause(15)
close all;

13 Comments

i successfull to display them in gui with sorting from similiar images to unsimiliar images..but its overwrite left area in GUI looks like this
this is my code
% Retrieval
k=1;
ThCM=70; %threshold perbandingan citra
for j=1:ukuranbaris
Sum = sum(abs(num(j,:)-databin));
if Sum < ThCM
Dist(k)= Sum;
k=k+1;
fileNm(k) = {raw{j+1,28}};
end
end
Sum
Dist
% fileNm{1}
% fileNm{2}
% fileNm{3}
% fileNm{4}
%sorting for most similiar images to unsimiliar images
[ImShr,Inx] = sort(Dist,'ascend');
pnf = size(Dist')
%program untuk menampilkan citra secara looping pada figure baru
% for k = 2 : pnf
% thisFileName = fileNm{k};
% ImgFile2 = imread(thisFileName);
% %display the image
% axes(handles.axes2) %the current axes should be set to axes1
% imagesc(ImgFile2); %displays the data in array C as an image that uses the full range of colors in the colormap
% %clear axes scale
% subplot(3,3,k),imshow(ImgFile2);
% hold on;
% axis off
% caption = sprintf('File %d of %d : "%s"', k, numel(fileNm), thisFileName)
% title(caption, 'FontSize', 5);
% drawnow;
%
% end
ImShr
Inx
% BIKIN WINDOW BARU
for k = 1 : pnf(1,1)
thisFileName = fileNm{Inx(k)+1};
% figure(1), subplot(3,4,k),imshow(thisFileName);
subplot(3,4,k+1),imshow(thisFileName);
% subplot(3, 4, 2);
% imshow(fileNm{2}); %gambar ke 2
% subplot(3, 4, 3);
% imshow(fileNm{3}); %gambar ke 3
% subplot(3, 4, 4);
% imshow(fileNm{4}); %gambar ke 4
% subplot(3, 4, 6);
% imshow(fileNm{5}); %gambar ke 5
% subplot(3, 4, 7);
% imshow(fileNm{6}); %gambar ke 6
% subplot(3, 4, 8);
% imshow(fileNm{7}); %gambar ke 7
% subplot(3, 4, 10);
% imshow(fileNm{8}); %gambar ke 8
% subplot(3, 4, 11);
% imshow(fileNm{9}); %gambar ke 9
% subplot(3, 4, 12);
% imshow(fileNm{10}); %gambar ke 10
% caption = sprintf('File %d of %d : "%s"', k, numel(fileNm), thisFileName);
% title(caption, 'FontSize', 5);
%hold on
drawnow;
end
pause(15)
close all;
Create a panel in your GUI to act as a parent, then you can use this to parent your subplots, as e.g.
hFig = figure;
p = uipanel( hFig );
hAxes(k) = subplot( 3, 4, 2, 'Parent', p );
Obviously you need to position the panel where you want it and can get rid of the border and whatever else you want to do, but that should work to group the plots where you want them.
Also I don't know what version of Matlab you are using, but if it is R2019b then
doc tiledLayout
gives more customisation options than subplot also.
im using matlab r2018a sir,okay .. i will try your solution
i just created panel in GUI like this..
but when i run your code it shows like this:
and here's my code
for k = 1 : pnf(1,1)
thisFileName = fileNm{Inx(k)+1};
% figure(1), subplot(3,4,k),imshow(thisFileName);
hFig = figure;
p = uipanel( hFig );
hAxes(k) = subplot( 3, 4, 2, 'Parent', p );
% subplot(3, 4, 2);
% imshow(fileNm{2}); %gambar ke 2
% subplot(3, 4, 3);
% imshow(fileNm{3}); %gambar ke 3
% subplot(3, 4, 4);
% imshow(fileNm{4}); %gambar ke 4
% subplot(3, 4, 6);
% imshow(fileNm{5}); %gambar ke 5
% subplot(3, 4, 7);
% imshow(fileNm{6}); %gambar ke 6
% subplot(3, 4, 8);
% imshow(fileNm{7}); %gambar ke 7
% subplot(3, 4, 10);
% imshow(fileNm{8}); %gambar ke 8
% subplot(3, 4, 11);
% imshow(fileNm{9}); %gambar ke 9
% subplot(3, 4, 12);
% imshow(fileNm{10}); %gambar ke 10
% caption = sprintf('File %d of %d : "%s"', k, numel(fileNm), thisFileName);
% title(caption, 'FontSize', 5);
%hold on
drawnow;
end
pause(15)
close all;
My code was just an example. Obviously in your case you have your panel in your GUI already so you use that panel where I use 'p' and don't create a new figure. I just did that to show an example of a panel in a figure.
okey i got it, but i don't know how to plot multiple image in panel..could you give me the full code sir?
You already have code creating all your subplots. Just parent them all to that panel.
i try this but get error..
for k = 1 : pnf(1,1)
thisFileName = fileNm{Inx(k)+1};
% figure(1), subplot(3,4,k),imshow(thisFileName);
p = uipanel( thisFileName );
hAxes(k) = subplot( 3, 4, 2, 'Parent', p );
% subplot(3, 4, 2);
% imshow(fileNm{2}); %gambar ke 2
% subplot(3, 4, 3);
% imshow(fileNm{3}); %gambar ke 3
% subplot(3, 4, 4);
% imshow(fileNm{4}); %gambar ke 4
% subplot(3, 4, 6);
% imshow(fileNm{5}); %gambar ke 5
% subplot(3, 4, 7);
% imshow(fileNm{6}); %gambar ke 6
% subplot(3, 4, 8);
% imshow(fileNm{7}); %gambar ke 7
% subplot(3, 4, 10);
% imshow(fileNm{8}); %gambar ke 8
% subplot(3, 4, 11);
% imshow(fileNm{9}); %gambar ke 9
% subplot(3, 4, 12);
% imshow(fileNm{10}); %gambar ke 10
% caption = sprintf('File %d of %d : "%s"', k, numel(fileNm), thisFileName);
% title(caption, 'FontSize', 5);
%hold on
drawnow;
end
pause(15)
close all;
You showed above that you added a panel to your GUIDE GUI. This panel will have a tag (I can't remember what the default is for a panel, but you can find it easily enough in in the Property Inspector. That is the panel you need to use as the parent. Don't create a new one, and if you do, you certainly don't want to just give it some arbitrary input argument that appears to be a filename.
Your panel will be something like
handles.uipanel1
but as I say, I can't remember exactly what the default tag is. I always give my components a tag of my own name anyway so I know what they are.
yes i got it sir, i know i hava a tag of my UIpanel from guide..but my problem is i dont know how to plot list of images with looping method like below into the panel in coding terms because im new in matlab..
for k = 1 : pnf(1,1)
thisFileName = fileNm{Inx(k)+1};
figure(1), subplot(3,4,k),imshow(thisFileName);
end
%this is my entire code
%nama file excel
filename = 'databin.xlsx';
data = [header;databincell fullname1 ];
sheet = 'binwarna';
%baca file excel
[num,txt,raw] = xlsread(filename,sheet);
ukuranbaris = size(num,1);
ukurankolom = size(raw,2);
databin
%menentukan nilai treshold
threshold = 1.6155;
%filter berdasarkan treshold
%idx = [raw{2,1:27}] > threshold
idx = [databin] > threshold
colnames = {raw{1,idx}};
% %set warna ke text5
set(handles.text6, 'String', colnames);
% Retrieval
k=1;
ThCM=70; %threshold perbandingan citra
for j=1:ukuranbaris
Sum = sum(abs(num(j,:)-databin));
if Sum < ThCM
Dist(k)= Sum;
k=k+1;
fileNm(k) = {raw{j+1,28}};
end
end
Sum
Dist
% fileNm{1}
% fileNm{2}
% fileNm{3}
% fileNm{4}
%sorting for most similiar images to unsimiliar images
[ImShr,Inx] = sort(Dist,'ascend');
pnf = size(Dist')
%program untuk menampilkan citra secara looping pada figure baru
% for k = 2 : pnf
% thisFileName = fileNm{k};
% ImgFile2 = imread(thisFileName);
% %display the image
% axes(handles.axes2) %the current axes should be set to axes1
% imagesc(ImgFile2); %displays the data in array C as an image that uses the full range of colors in the colormap
% %clear axes scale
% subplot(3,3,k),imshow(ImgFile2);
% hold on;
% axis off
% caption = sprintf('File %d of %d : "%s"', k, numel(fileNm), thisFileName)
% title(caption, 'FontSize', 5);
% drawnow;
%
% end
ImShr
Inx
whos Inx
Inx(1)
Inx(2)
Inx(3)
% BIKIN WINDOW BARU
for k = 1 : pnf(1,1)
thisFileName = fileNm{Inx(k)+1};
figure(1), subplot(3,4,k),imshow(thisFileName);
% subplot(3, 4, 2);
% imshow(fileNm{Inx(2)}); %gambar ke 2
% subplot(3, 4, 3);
% imshow(fileNm{Inx(3)}); %gambar ke 3
% subplot(3, 4, 4);
% imshow(fileNm{Inx(4)}); %gambar ke 4
% subplot(3, 4, 6);
% imshow(fileNm{Inx(5)}); %gambar ke 5
% subplot(3, 4, 7);
% imshow(fileNm{Inx(6)}); %gambar ke 6
% subplot(3, 4, 8);
% imshow(fileNm{Inx(7)}); %gambar ke 7
% subplot(3, 4, 10);
% imshow(fileNm{Inx(8)}); %gambar ke 8
% subplot(3, 4, 11);
% imshow(fileNm{Inx(9)}); %gambar ke 9
% subplot(3, 4, 12);
% imshow(fileNm{10}); %gambar ke 10
% caption = sprintf('File %d of %d : "%s"', k, numel(fileNm), thisFileName);
% title(caption, 'FontSize', 5);
%hold on
drawnow;
end
pause(15)
close all;
and i hope you can help me with coding sir, i just share my entire script to you
Attach both your m-file and fig-file with the paper clip icon.

Sign in to comment.

Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Asked:

on 24 Feb 2020

Commented:

on 26 Feb 2020

Community Treasure Hunt

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

Start Hunting!