GPT答: |
7i24.cn
|
```matlab
% 读取物体图像和背景图像
object_img = imread('object.jpg');
background_img = imread('background.jpg');
% 图像叠加
added_img = object_img + background_img;
% 显示叠加的图像
figure;
subplot(1,3,1);
imshow(object_img);
title('Object Image');
subplot(1,3,2);
imshow(background_img);
title('Background Image');
subplot(1,3,3);
imshow(added_img);
title('Added Image');
% 图像分离
separated_object_img = added_img - background_image;
% 显示分离出的物体图像
figure;
subplot(1,2,1);
imshow(separated_object_image);
title('Separated Object Image');
subplot(1,2,2)
imshow(background_image)
title('Background Image')
% 图像局部显示效果(掩膜矩阵)
mask = zeros(size(object_image));
mask(100:200 , 150:250) = 255; % 设定关注区域为矩形区域
masked_object_image = object_image .* uint8(mask);
figure;
subplot(1,2 , 1)
imshow(object_image)
title("Original Object Image")
subplot (122 )
imshow(masked_object_ image )
title ("Masked Object I mage ")
```
|