how to display an image

6 visualizaciones (últimos 30 días)
Blazej Staniak
Blazej Staniak el 30 de Nov. de 2021
Respondida: yanqi liu el 1 de Dic. de 2021
Hello, i have a part of a program that recognizes my letters, everything looks nice the program recognized. But I have such a problem, I would like to show it in the program. After doing this, how do you present it in the form as in the attachment. I am pasting the code below
for n= 1: length(propied)
BBs= propied(n).BoundingBox;
subImage= imresize(imcrop(im, BBs), [150 80]);
baseFileName = sprintf('Obraz #%d.png', n);
fullFileName = fullfile(string(newSubFolder(1)), baseFileName);
imwrite(~subImage, fullFileName);
hold on;
subplot (1, 8, n);
set(gcf, 'Position', get(0,'Screensize'));
figure(11), imshow(subImage);
end
close all;

Respuestas (3)

Spectro
Spectro el 30 de Nov. de 2021
What about using just tiledlayout? See the attachment (code below).
M = ones(400, 200);
tiledlayout(1, 6, 'TileSpacing', 'tight')
nexttile;imshow(M)
nexttile;imshow(M)
nexttile;imshow(M)
nexttile;imshow(M)
nexttile;imshow(M)
nexttile;imshow(M)

Image Analyst
Image Analyst el 1 de Dic. de 2021
Looks like it should work, though I'd pull figure(11) outside the loop and put it before the loop. Did it now work like you expected? This is how I'd do it (untested):
% Create a new figure called hFig.
hFig = figure();
numDigits = length(propied);
for n = 1 : numDigits
% Crop out this digit from the larger image and resize it to 150 rows by 80 columns.
BBs = propied(n).BoundingBox;
subImage = imresize(imcrop(im, BBs), [150, 80]);
% Display this subimage in its own axes.
subplot (1, numDigits, n);
imshow(subImage);
% Create a filename and save the subimage to its own disk file.
baseFileName = sprintf('Obraz #%d.png', n);
fullFileName = fullfile(string(newSubFolder(1)), baseFileName);
imwrite(~subImage, fullFileName);
end
g = gcf;
g.WindowState = 'maximized';
% Ask user if they want to close the figure.
promptMessage = sprintf('Do you want to close the figure now?');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Yes', 'No - leave it up', 'Yes');
if contains(buttonText, 'Yes', 'IgnoreCase', true)
% They want to close it.
close(hFig);
end

yanqi liu
yanqi liu el 1 de Dic. de 2021
yes,sir,may be use
figure(11); clf;
set(gcf, 'Position', get(0,'Screensize'));
for n= 1: length(propied)
BBs= propied(n).BoundingBox;
subImage= imresize(imcrop(im, BBs), [150 80]);
baseFileName = sprintf('Obraz #%d.png', n);
fullFileName = fullfile(string(newSubFolder(1)), baseFileName);
imwrite(~subImage, fullFileName);
figure(11);
subplot (1, 8, n);
imshow(subImage, []);
end

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by