Taking slices from several images and stitching them together
1 view (last 30 days)
Show older comments
Hi everyone, i have several images like the one which can be seen here :
In all images the location of the two bars are always in the same position on the y axis. They only change intensity.
I would like to take a pixel row at a certain height on the y axis of all images, stitch them together and display the resulting image.
So far i have the following in Matlab:
A =imread('image0000000351.pgm');
A = floor(A./16); % transform back to 12 bit
[n m] = size(A);
B=A-400; % remove background noise
imagesc(B);
I'm a bit lost at this stage. How would i proceed to cut a slice on the y axis for several images and stich them together?
0 Comments
Answers (1)
Image Analyst
on 17 Jan 2015
Just extract the line from this image and add it into some accumulation line.
sumOfLines = zeros(numberOfImages, columns);
for k = 1 : numberOfImages
% Read image.....
baseFileName = sprintf('image....... whatever.....
fullFileName = fullfile(folder, baseFileName);
A =imread(fullFileName);
A = floor(A./16); % transform back to 12 bit
B = A - 400; % remove background noise
imshow(B);
thisLine = B(desiredRow, :);
sumOfLines = sumOfLines + double(thisLine);
drawnow;
pause(0.2); % Wait long enough to see it.
end
averageLine = sumOfLines / numberOfImages;
plot(sumOfLines, 'b-');
grid on;
You need to figure out the number of lines and the number of columns but there are ways to do that - either you know in advance or you check the size after you read in the very first image. And of course you might want to make it more robust by checking that the number of columns is the same for every image, and that the image actually exists before you try to read it in.
4 Comments
Image Analyst
on 18 Jan 2015
Sorry, actually sumOfLines should be a 1D array:
sumOfLines = zeros(columns);
See Also
Categories
Find more on Geometric Transformation and Image Registration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!