- imgradient - https://www.mathworks.com/help/images/ref/imgradient.html
- mat2gray - https://www.mathworks.com/help/images/ref/mat2gray.html
- ind2rgb - https://www.mathworks.com/help/matlab/ref/ind2rgb.html
How to provide pseudo (false) color to inverse fast fourier transformed image (IFFT)
5 次查看(过去 30 天)
显示 更早的评论
Hello, and thanks in advance.
I have post-processed an image (code is given below)
image=imread('my_image.jpg'); % read out the image file (RGB image)
subcrop=rgb2gray(imcrop(image,[415 59 526 687])); % crop the region of interest
T=fft2(subcrop); % fast fourier transformation of cropped image
FFT=T; % store into another variable named FFT
FFTS=fftshift(FFT); % shift the frequency of image to the center of FFT frequency domain
FFT2=(FFTS-min(min(FFTS)))./(max(max(FFTS))).*255;
imshow(FFT2) % diaplay the centre shifted frequency
[r,c]=size(subcrop); % creating a matrix of same size of image
TS=circshift(FFTS,77); % shift the pole by a value of 77 (1st order frequency) to the center (zeroth order frequency) , this step is requirement of the objective
gauss=fspecial('gaussian',[r,c],19); % creating a gaussina filter of size r,c
gaussian=mat2gray(gauss);
SP=TS.*gaussian; % multiplying TS with a gaussian filter
output_image=(ifft2(SP)); % inverse FFT of SP
imshow(output_image) % display the final output
Now I wanted to provide fasle or Pseudo color to 'output_image" based on intesnity gradient but I am unable to add this.
I have tried using rgb2ind as well as real(), imag() but these are not working.
Please help me in order to solve this problem, your help will be highly appriciated.
raw image (rgb) and post-processed images are attached
0 个评论
回答(1 个)
Paras Gupta
2023-11-18
Hi Anurag,
I understand that you want to apply a pseudo-color to your processed image based on intensity gradients. The following code illsutarates one way to achieve the same in MATLAB.
% Extracting real part
temp = real(output_image);
% Calculate intensity gradient
[~, intensityGradient] = imgradient(temp, 'sobel'); % Using Sobel operator for gradient calculation
% Normalize gradient values to range [0, 1]
normalizedGradient = mat2gray(intensityGradient);
% Map the gradient to a pseudo-color image
gradientPseudoColor = ind2rgb(uint8(normalizedGradient * 255), jet(255)); % Using 'jet' colormap
% Or create an RGB image using the normalized gradient as the intensity for all channels
% gradientPseudoColor = cat(3, normalizedGradient, normalizedGradient, normalizedGradient);
% Display the pseudo-color image
imshow(gradientPseudoColor);
You can refer to the following documentation links for information on the functions used in the code:
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!