MATLAB-如何将一个图像放在另一个图像上? [英] MATLAB-How to put one image on another?

查看:2192
本文介绍了MATLAB-如何将一个图像放在另一个图像上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张图片

我已经使用fftn函数获得了仅相位重建图像。

I have obtained its phase only reconstructed image using fftn function.

我的目标是



  1. 使用仅相位重建给定图像,我将只得到边和线

  1. Using phase only reconstruction of the given image,i will get only edges and lines

然后我想为这些线条着色,边缘在仅相位重建图像中用红色或蓝色表示。

Then i want to color these lines and edges say with red or blue color in the phase only reconstructed image.

然后我想把这张彩色图像放在原始图像上,这样原始图像的边缘和线条就可以用相应的红色或蓝色高亮一点颜色。

Then i want to put this "colored" image on original image so that edges and lines from the original images can be high-lightened with respective red or blue color.


但是当我运行代码时,我得到以下错误

But when i run the code, i get following error

'下标索引必须是实数正整数或逻辑。

'Subscript indices must either be real positive integers or logicals.

sagar_image中的错误(第17行)
叠加(ph)= 255;'

Error in sagar_image (line 17) superimposing(ph) = 255;'

那我该怎么办?

clc;
close all;
clear all;

img=imread('D:\baby2.jpg');
figure,imshow(img);
img=rgb2gray(img);

fourier_transform=fftn(img);%take fourier transform of gray scale image

phase=exp(1j*angle(fourier_transform));
phase_only=ifftn(phase);%compute phase only reconstruction
figure,imshow(phase_only,[]);

ph=im2uint8(phase_only);%convert image from double to uint8 
superimposing = img;
superimposing(ph) = 255;  
figure,
imshow(superimposing,[]), 


推荐答案

叠加(ph)= 255可能意味着 -
1. ph包含您希望绘制白色的叠加指数(255)。
2. ph是一个与叠加相同大小的逻辑图像,在ph中评估为true的每个像素都会在叠加时涂成白色。

superimposing(ph) = 255 could mean - 1. ph contains indices of superimposing that you wish to paint white(255). 2. ph is a 'logical' image of the same size as superimposing, every pixel that evaluates to 'true' in ph would be painted white in superimposing.

你的意思可能是:

threshold = 0.2;
superimposing(real(phase_only) > threshold) = 255;

如果你想融合两张图片并在另一张图片上面看到它们,请使用imfuse:

If you want to fuse the two images and see them one on top of the other use imfuse:

imshow(imfuse(real(phase_only), img, 'blend'))

这篇关于MATLAB-如何将一个图像放在另一个图像上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆