[英]MATLAB-How to put one image on another?
I have an image 我有一张图片
I have obtained its phase only reconstructed image using fftn function. 我已经使用fftn函数获得了仅相位重建的图像。
My aim is 我的目的是
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. '下标索引必须是实数正整数或逻辑值。
Error in sagar_image (line 17) superimposing(ph) = 255;' sagar_image(第17行)叠加(ph)= 255时出错;
So what should I do? 所以我该怎么做?
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,[]),
superimposing(ph) = 255 could mean - 1. ph contains indices of superimposing that you wish to paint white(255). superimposed(ph)= 255可能意味着-1。ph包含您希望绘制白色(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. 2. ph是与叠加大小相同的“逻辑”图像,每个在ph中评估为“ true”的像素在叠加时都会被涂成白色。
What you meant was probably: 您的意思可能是:
threshold = 0.2;
superimposing(real(phase_only) > threshold) = 255;
If you want to fuse the two images and see them one on top of the other use imfuse: 如果要融合两个图像,并在另一个图像上看到它们,请使用imfuse:
imshow(imfuse(real(phase_only), img, 'blend'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.