필터 지우기
필터 지우기

how to show the images of a uint8 format cell array through a montage in a single image?

조회 수: 2 (최근 30일)
Hi! i've this cell array that contains my images :
a =
1×14 cell array
Columns 1 through 5
{246×272×3 uint8} {246×272×3 uint8} {246×272×3 uint8} {246×272×3 uint8} {246×272×3 uint8}
Columns 6 through 10
{246×272×3 uint8} {251×280×3 uint8} {240×264×3 uint8} {232×248×3 uint8} {232×264×3 uint8}
Columns 11 through 14
{232×264×3 uint8} {168×200×3 uint8} {238×272×3 uint8} {232×256×3 uint8}
and i want to show them all in one figure with montage i've tried this
for i = 1 : 14
montage(a{i:14} ,'Size',[2 7])
end
but everytime opens a new figure and i want to show all my 14 figures all together in one figure window
thanks

채택된 답변

Ashish Uthama
Ashish Uthama 2018년 10월 17일
If you have a newer version, try using IMTILE to create the individual montage for each cell array element. Air code:
mim = {}
for i = 1 : 14
mim{i} = imtile(a{i:14} ,'Size',[2 7])
end
montage(mim)

추가 답변 (2개)

Image Analyst
Image Analyst 2018년 10월 16일
Try using it this way (untested by me):
img = montage(a,'Size',[2 7])
imshow(img);
In other words, don't use a for loop and accept the output of montage into a new variable rather than ignoring it.
  댓글 수: 4
federica pasquali
federica pasquali 2018년 10월 17일
a it's the same cell array i've put in the original question
Jan
Jan 2018년 10월 17일
@federica pasquali: According to the documentation, such an "imageList" is a valid input:
imagelist — Set of images
n-by-1 or 1-by-n cell array
Set of images, specified as an n-by-1 or 1-by-n cell array of
numeric matrices of size m-by-n or m-by-n-by-3.
Data Types: single | double | int16 | uint8 | uint16 | logical | cell
So please post a minimal working example, which reproduces the error message. Replace the image data by some rand calls.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2018년 10월 17일
Use the 'parent' input option to place the resulting montage image where you want. For example:
% Specify the folder where the files live.
myFolder = fileparts(which('cameraman.tif')); % Determine where demo folder is (works with all versions).
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.png'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
numImages = length(theFiles);
allImages = cell(1, numImages);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
imageArray = imread(fullFileName);
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
allImages{k} = imageArray;
end
% Create the montage:
fprintf('Done reading in images. Now building %d by %d montage...\n', rows, rows);
rows = ceil(sqrt(numImages));
mImage = montage(allImages, 'Size', [rows, rows], 'Parent', gca);
caption = sprintf('Montage of %d images', numImages);
title(caption, 'FontSize', 15);
fprintf('Done reading in images. Now building montage...\n');

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by