MATLAB - How to put one image on another?

I have an image

enter image description here

I only got the phase-reconstructed image using the fftn function.

My goal

  • Using only reconstruction of this image, I get only edges and lines

  • Then I want to color these lines and edges with red or blue in the phase-reconstructed image only.

  • Then I want to put this “color” image on the original image so that the edges and lines from the original images can be strongly illuminated with the corresponding red or blue color.

But when I run the code, I get the following error

'Indexes indices must be either natural integers or logical.

Error in sagar_image (line 17) overlay (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,[]), 
+1
source share
1 answer

overlay (ph) = 255 can mean - 1. ph contains overlay indices that you want to paint white (255). 2. ph is a “logical” image of the same size as the overlay, each pixel that evaluates to “true” in ph will be painted white in the overlay.

What you meant is probably:

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

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

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

All Articles