Merging multiple jpg files into a single image

Hi everyone, I have 97 uint8 jpgs (black and white) that I want to merge into a single jpg. However I need the final combined image to only be composed of cells from the series which are white.
I have tried using the imfuse command but it only works for 2 images and just over lays the images which is not what I need to do.
Any help would be greatly appreciated.

4 Comments

Can you elaborate, is the size of the final image the same as the original frames? Are only the white pixels of the 97 frames supposed to be in the final frame? Since the frame are uint8 which pixel values do you consider as white? 255 only or something less is also valid?
Sorry about that. The only values in the images are 0 and 255. The the size of the final image needs to be the same as the input images (760x1020). Yes only those cells with 255 need to be added to the final image. I am basically trying to track the progression of an active lava flow through a time series of thermal images. I have attached a few of the jpgs to help give a visual sense of what is going on.
I started writing something along the lines of
Image_totArea = (sum(sum(image_name1 > 0))+(sum(sum(image_name2 >0)))+...
which seems to work but I am not sure how to go about referencing the growth in a for loop?
Well that's not right - why would you do that? Did you see my answer?
By the way, never use JPEG images when you need to do image analysis. Your pixels won't be just 0 and 255 - there will be in between values with jpg format. Use PNG format instead.
Thanks for the answer and the suggestion on output format. We normally don't use a visual format in our workflow but needed to in this particular instance. I will make a note of the .png suggestion for the future.

Sign in to comment.

 Accepted Answer

Just OR the binary images:
folder = 'c:\myimages'; % Whatever..
for k = 1 : numberOfImages
filename = sprintf('image_%d.png', k); % Whatever.
fullFileName = fullfile(folder, filename);
if exist(fullFileName, 'file')
thisImage = imread(fullFileName);
binaryImage = thisImage > 128; % Or whatever.
if k == 1
output = binaryImage;
else
output = output | binaryImage;
end
end
end
% If you want 0 and 255 instead of 0 and 1, set to 255 the "1" pixels
output(output== 1) = 255;

1 Comment

To get the sum of pixels in the output, just sum the output (before it gets multiplied by 255) to get the area
pixelSum = sum(output(:));

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type 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!