I tried to apply 'emd' function on image to get output image with IMFs selected. But got stuck at the errors. Thanks in Advance.
4 views (last 30 days)
Show older comments
Applied EMD function to image and tried to get first Two IMFs and reconstruct the image with them. But got error in reshape step. Thanks in Advance if i solution in this.
%% Calculate First 2 IMFs from Image by 'emd' and reconstruct the image
clc
clear all
close all
% Test on 03.05.2023
% Read the image
img = imread('D:\Search Works\356-inputs.png');
% Convert the image to grayscale
img_gray = rgb2gray(img);
img_grey = im2double(img_gray);
% Reshape image into a 1D vector
img_vec = img_grey(:);
% Perform EMD
imf = emd(img_vec);
% Take only first two IMFs
imf = imf(1:2,:);
% Reshape the IMFs back into a 2D matrix
imf_mat = permute(imf, [2 1]);
imf_mat = reshape(imf_mat, [size(img_grey), size(imf,1)]);
% Display the first two IMFs
subplot(1,3,1), imshow(img_gray), title('Original Image');
subplot(1,3,2), imshow(imf_mat(:,:,1)), title('IMF 1');
subplot(1,3,3), imshow(imf_mat(:,:,2)), title('IMF 2');
0 Comments
Answers (0)
See Also
Categories
Find more on Denoising and Compression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!