fusion of satellite images
2 views (last 30 days)
Show older comments
Hello
I want to make a fusion between 3 image (satellite type image attached) I tried with this code but it did not work someone has an idea and thank you in advance.
image(:,:,1)= load('C1fig.mat');
image(:,:,2)= load('C2fig.mat');
image(:,:,3)= load('C3fig.mat');
0 Comments
Accepted Answer
Guillaume
on 24 Jan 2019
First, don't use image as a variable name, it's already the name of a matlab function that you may want to use. In the same vein, don't name your variables ans (as they are named in the mat files). This is a special variable in matlab. If these ans variable come from a function, then call that function with an output variable with a sensible name instead of calling that function with no output.
load with an output variable (which is the correct way to use load) creates a structure where each field is one of the variable in the mat file. So your first load will create field ans in image(:,:,1) variable. Because load always return a scalar structure, the : are equivalent to 1. With your code, you are in effect creating a 1x1x3 structure with field ans. A simpler and clearer way to achieve this is with:
imgs = []; %make sure it's empty before we load the mat file. Not calling it image but imgs
imgs(1) = load('C1fig.mat');
imgs(2) = load('C2fig.mat');
imgs(3) = load('C3fig.mat');
Now, it's not clear what you call fusion. Going by your original code, it looks like you want to merge all three greyscale images as a true colour image, with the first one being the red channel, the second the blue channel and the third the red channel. If that's the case, then:
img = cat(3, imgs.ans);
imshow(img)
If by fusion you mean something else entirely, then you need to clarify.
4 Comments
Eylem Dalgic
on 7 Dec 2021
So how can we do this with a loop if there are too many images in jpg format?
More Answers (0)
See Also
Categories
Find more on Image Data Workflows 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!