In this tutorial, I’m gonna show you how to create hybrid images . Basically, you need to filter your first image with high pass filter and the second image with a low pass filter and then add theses two images. The following code shows how to do that. The full code is available at my GitHub.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
first_image_path='../images/obama.jpg'; second_image_path='../images/michelle_obama.jpg'; first_image=im2double( rgb2gray( imread(first_image_path) ) ); second_image=im2double( rgb2gray( imread(second_image_path) ) ); sigma=6; gaussian_dimension=3*sigma*2+1; first_image_high_pass_filtered=highPassFilter(first_image,gaussian_dimension); figure('Name','first_image_high_pass_filtered'), imshow(first_image_high_pass_filtered,[]); sigma=1; gaussian_dimension=3*sigma*2+1; second_image_low_pass_filtered=lowPassFilter(second_image,gaussian_dimension); figure('Name','second_image_low_pass_filtered'), imshow(second_image_low_pass_filtered,[]); final_image=second_image_low_pass_filtered+first_image_high_pass_filtered; figure('Name','second_image_low_pass_filtered'), imshow(final_image, []); |