How to fuse multiple images while retaining the color of the original images and changing some image colors?

8 次查看(过去 30 天)
Hello, all,
I am trying to fuse multiple images together to form a final image with the original colors in the original images, however, when I fuse them together, they are mixing and blending the colors to be a completely different color from what I am looking for.
Can I get some insight on solving this please?
Final Image that needs help fixing the colors:
Full map image stored as 600x600x3 uint8:
Fastest path image (the white pixels here need to be green to indicate the fastest path in the final image) stored as 600x600x3 uint8:
Trajectory recorded (the black and magenta pixels) not the exact example from the above images but they are in the same structure:
Stored in workspace as: matImgRGB in a 600x600 uint8 and this is the outcome when using infuse() with the Fastest path image above:
The final image should be the green fastest path image with the colors of the tracjectory recorded overlaid with the full map image with it's blue color. Appreciate the help!
Many thanks,
Michael

采纳的回答

DGM
DGM 2024-5-11
编辑:DGM 2024-5-11
IPT imfuse() is not an image compositing tool. It's a simple tool for visually comparing two images. This is why everything is turning inconsistent shades of green:
The answer is to not use imfuse(). Identify which image (if any) is to be the background, and create masks from the others. Then compose the output image based on those masks and whatever feature colors you want. I'm going to make some assumptions for the sake of example, but this should be a start.
% read the images
% i'm assuming these are already the same size
% i don't know where you're getting the trajectory image
% i just created this one from the screenshot
fullmap = imread('fullmap.png'); % 600x600 RGB uint8
fastpath = imread('fastpath.png'); % 600x600 RGB uint8
tjmask = imread('trajectory.png'); % 600x600 I logical
% convert fastpath to a simple grayscale mask
% if the trajectory image is also RGB, do similar to it.
fpmask = imadjust(im2gray(fastpath));
% pick your colors
fpcolor = [0 1 0];
tjcolor = [0.5 0 0];
% compose the output
% this is how i'd do it in MIMT, safe and class/depth agnostic
%outpict = replacepixels(fpcolor,fullmap,fpmask);
%outpict = replacepixels(tjcolor,outpict,tjmask);
% this mess is how it's done in IPT
fpmask = im2double(fpmask);
tjmask = im2double(tjmask);
outpict = fpmask.*permute(fpcolor,[1 3 2]) + (1-fpmask).*im2double(fullmap);
outpict = tjmask.*permute(tjcolor,[1 3 2]) + (1-tjmask).*im2double(outpict);
outpict = im2uint8(outpict); % presume the output class
% show the output
imshow(outpict,'border','tight')
  6 个评论
Image Analyst
Image Analyst 2024-5-14
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by