how to display images in separate figures?

9 visualizzazioni (ultimi 30 giorni)
Mirsamir Salahov
Mirsamir Salahov il 30 Mag 2020
Risposto: Image Analyst il 30 Mag 2020
I have already implemented my images I need to work with in matlab with imread
Now I want to open each image in one figure. I want to know how I can it open them without wirting severel times the same thing.
I tried it like this but it doesn't work:
for k = 1:8
name = ['im', num2str(k)];
figure; imshow(name)
end

Risposte (2)

Image Analyst
Image Analyst il 30 Mag 2020
What is the extension? Let's say it's png, and you have im1.png, im2.png, etc. So see the FAQ: https://matlab.fandom.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
You need to do something like this:
% Read im1.png through im8.png. Files are in the current directory.
% Change the call to fullfile() if you need to prepend some other folder than the current folder.
for k = 1 : 8
% Create an image filename, and read it in to a variable called thisImage.
baseFileName = sprintf('im%d.png', k);
fullFileName = fullfile(pwd, baseFileName);
if isfile(fullFileName)
thisImage = imread(fullFileName);
else
fprintf('File %s does not exist.\n', fullFileName);
end
% Display the image.
figure % Bring up a new figure;
imshow(thisImage, []);
axis('on', 'image');
caption = sprintf('"%s"', baseFileName);
title(caption, 'FontSize', 15);
end

madhan ravi
madhan ravi il 30 Mag 2020
for k = 1:8
figure(k)
I = imread(sprintf('im%d',k)); % you forgot to read the image
imshow(I)
end
  9 Commenti
madhan ravi
madhan ravi il 30 Mag 2020
Man you are complicating a simple problem.

Accedi per commentare.

Categorie

Scopri di più su Display Image in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by