I am using Matlab R2018a and i am using a x ray image (skull) as my input image.I want to convert my final image (B2) to grayscale image.Can you please suggest a method for this?
And also i want to save my final result.When i am using saveas it gives me an error.Can you please help me to solve this issue? Here is the code that i have run so far.
close all;clear all;clc;img = imread('055.bmp');img2 = imnoise(img,'salt & pepper',0.025);img3 = img2;for c = 1 : 3img3(:, :, c) = medfilt2(img2(:, :, c), [5, 5]);%add median filter
endI=rgb2gray(img3); % convert the image to grey
A = fft2(double(I)); % compute FFT of the grey image
A1=fftshift(A); % frequency scaling
% Gaussian Filter Response Calculation
[M, N]=size(A); % image size
R=15; % filter size parameter
X=0:N-1;Y=0:M-1;[X, Y]=meshgrid(X,Y);Cx=0.3*N;Cy=0.3*M;Lo=exp(-((X-Cx).^2+(Y-Cy).^2)./(2*R).^2);Hi=1-Lo; % High pass filter=1-low pass filter
% Filtered image=ifft(filter response*fft(original image))
J=A1.*Lo;J1=ifftshift(J);B1=ifft2(J1);K=A1.*Hi;K1=ifftshift(K);B2=ifft2(K1);%----visualizing the results----------------------------------------------
figure(1)subplot(2,2,1)imshow(I);colormap graytitle('Original image')subplot(2,2,2)imshow(img3);colormap graytitle('Median Filterd image')subplot(2,2,3)imshow(abs(A1),[-12 300000]), colormap graytitle('fft of original image')subplot(2,2,4)imshow(abs(B2),[12 290]), colormap graytitle('High pass filtered image')figure(2)subplot(1,3,1);imshow(img)title('Original image')subplot(1,3,2);imshow(img3)title('Median filtered image')subplot(1,3,3);imshow(abs(B2),[12 290])title('High pass filtered image')
Best Answer