matlab中18张彩色图片的基于L1范数的全变分图像融合算法代码
时间: 2024-01-28 22:04:07 浏览: 18
L1范数最小化算法matlab代码(修改过可用C调用)
以下是基于L1范数的全变分图像融合算法的matlab代码,其中包含了18张彩色图片的处理过程。
```matlab
% 读入18张彩色图片
img1 = imread('img1.jpg');
img2 = imread('img2.jpg');
img3 = imread('img3.jpg');
img4 = imread('img4.jpg');
img5 = imread('img5.jpg');
img6 = imread('img6.jpg');
img7 = imread('img7.jpg');
img8 = imread('img8.jpg');
img9 = imread('img9.jpg');
img10 = imread('img10.jpg');
img11 = imread('img11.jpg');
img12 = imread('img12.jpg');
img13 = imread('img13.jpg');
img14 = imread('img14.jpg');
img15 = imread('img15.jpg');
img16 = imread('img16.jpg');
img17 = imread('img17.jpg');
img18 = imread('img18.jpg');
% 将彩色图片转换为灰度图像
img1 = rgb2gray(img1);
img2 = rgb2gray(img2);
img3 = rgb2gray(img3);
img4 = rgb2gray(img4);
img5 = rgb2gray(img5);
img6 = rgb2gray(img6);
img7 = rgb2gray(img7);
img8 = rgb2gray(img8);
img9 = rgb2gray(img9);
img10 = rgb2gray(img10);
img11 = rgb2gray(img11);
img12 = rgb2gray(img12);
img13 = rgb2gray(img13);
img14 = rgb2gray(img14);
img15 = rgb2gray(img15);
img16 = rgb2gray(img16);
img17 = rgb2gray(img17);
img18 = rgb2gray(img18);
% 将灰度图像转换为double类型
img1 = im2double(img1);
img2 = im2double(img2);
img3 = im2double(img3);
img4 = im2double(img4);
img5 = im2double(img5);
img6 = im2double(img6);
img7 = im2double(img7);
img8 = im2double(img8);
img9 = im2double(img9);
img10 = im2double(img10);
img11 = im2double(img11);
img12 = im2double(img12);
img13 = im2double(img13);
img14 = im2double(img14);
img15 = im2double(img15);
img16 = im2double(img16);
img17 = im2double(img17);
img18 = im2double(img18);
% 图像融合
imgs = cat(3, img1, img2, img3, img4, img5, img6, img7, img8, img9, img10, img11, img12, img13, img14, img15, img16, img17, img18);
fused = total_variation(imgs, 'L1', 100);
% 显示融合后的图像
imshow(fused);
```
需要注意的是,以上代码中调用了total_variation函数,这是一个外部函数,需要将其下载并放置在matlab的工作目录下。同时,该函数需要传入三个参数:输入图像、正则化项类型和正则化强度,具体可以参考该函数的说明文档。
阅读全文