set up an array containing the images
이전 댓글 표시
Hello everyone ,i am trying to solve this exercice i am stuglling finding out the code for the first part of creating an erray of the images any help is appreciated
Use the sequence of cell images ( 'AT3 lm4 01.tif , 'AT3 lm4 02.tif, ..."
"'AT3 lln4 09.tif', 'AT3 lln4 10.tif') provided in cmnbination with the Matlab irnabsd if f() function and a Matlab for loop const ruct to display an ani1nation of the differences between i1nages in the sequence."
You may wish to use an additional enhancement approach to improve the dy namic range
of difference images that result from the irnabsd iff() function. What is result of this differencing operation? How could this be useful?
H int. You may wish to set up an array containing each of the image file names 01 to 10.
The animation effect can be achieved by updating the same figure for each set of differences (e.g. between the kth and ( k - l)th images in the sequence) or by investigating the Matlab
irnplay() function to play back an array of itnages.
this what i did please correct if it's false
for i=1:9
fn=strcat('AT3_1M4_0',num2str(i));
fn=strcat(fn,'.tif');
I(:,:,i)=imread(fn);
end
I(:,:,10)=imread('AT3_1M4_10.tif');
for i=1:9
subplot(3,3,i)
D=imabsdiff(I(:,:,i),I(:,:,i+1));
imshow(D);
end
댓글 수: 5
Geoff Hayes
2020년 4월 11일
souha - I suspect that the above code fails. Please include the error message that you are observing. Also, provide some details on your images - are they all the same size, are they 2D (grayscale) or not, what is I, etc.?
I would probably set I to a cell array and would initialie the array as
images = cell(10,1);
for k = 1:10
fn = sprintf('AT3_1M4_%02d.tif', k);
I{k} = imread(fn);
end
As for the subsequent loop, why do you have a subplot? I think the intention is to create an animation so you will want to re-use the same axes for each image.
sukam
2020년 4월 11일
Image Analyst
2020년 4월 11일
Did you ever try my code below? It works.
sukam
2020년 4월 12일
답변 (1개)
Image Analyst
2020년 4월 11일
편집: Image Analyst
2020년 4월 11일
Looks like it should work but you might use [] in imshow() to enhance the dynamic range as it suggested, and don't use i (the imaginary variable) as a loop iterator:
% Find the folder with all the demo images that ship with the Image Processing Toolbox.
folder = fileparts(which('AT3_1M4_01.tif')) % Determine where demo folder is.
for k = 1 : 10
baseFileName = sprintf('AT3_1M4_%2.2d.tif', k);
fullFileName = fullfile(folder, baseFileName);
if isfile(fullFileName)
thisImage = imread(fullFileName);
if k == 1
% Instantiate the whole 3-D array once we know the size of the first image.
[rows, columns, numberOfColorChannels] = size(thisImage);
allImages = zeros(rows, columns, 10, class(thisImage));
end
allImages(:,:, k) = imread(fullFileName);
imshow(allImages(:,:, k), []);
title(baseFileName, 'FontSize', 15);
drawnow;
end
end
hFig = figure; % Bring up a new figure.
hFig.WindowState = 'maximized';
for k = 2 : 10
subplot(3, 3, k-1);
diffImage = imabsdiff(allImages(:,:, k), allImages(:,:, k-1));
imshow(diffImage, []);
caption = sprintf('Image %d - Image %d', k, k+1);
title(caption, 'FontSize', 15);
end
though I'd do it somewhat differently than that (single loop instead of 2 loops)
카테고리
도움말 센터 및 File Exchange에서 Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


