how to apply histogram and median filters for a jpg imag??

1 view (last 30 days)
when i apply to the image it is showing error
Error using medfilt2
Expected input number 1, A, to be two-dimensional.
Error in medfilt2>parse_inputs (line 110)
validateattributes(a, {'numeric','logical'}, {'2d','real'}, mfilename, 'A', 1);
Error in medfilt2 (line 47)
[a, mn, padopt] = parse_inputs(varargin{:});
Error in medhistfilter (line 7)
m=medfilt2(pic);
how do i overcome this??
  9 Comments
Image Analyst
Image Analyst on 24 Jun 2014
Sorry, I don't see in your code where you area extracting one color channel or are calling rgb2gray(). Where is that?
seshi reddy
seshi reddy on 24 Jun 2014
clear;
clc;
pic=imread('C:\masters courses\applications of dsp\project2\GW_1200.jpg');
grayImage = rgb2gray(pic);
subplot(3,3,1);
imshow(grayimage);
title('original image');
m=medfilt2(grayimage);
subplot(3,3,2);
imshow(m);
title('Median Fileter of image');
a10=histeq(grayimage);
subplot(3,3,3);
imshow(a10);
title('Histogram equalization of image');

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 24 Jun 2014
pic is probably a color image. Either take one of the color channels
oneChannel = pic(:,:,2); % Take green channel.
or convert to gray scale
grayImage = rgb2gray(pic);
  7 Comments
Abdulmu'min Musa
Abdulmu'min Musa on 1 Apr 2020
Thanks, but what i mean here is that i dont want to use the "subplot" code but the "figure" code, so that each of the image will be displayed seperately.
I want to create a new figure window to display the gray image, another figure window to display median filtered image and another figure window to display histogram equalized image.
Pls help. Thanks
Image Analyst
Image Analyst on 1 Apr 2020
Well just make the obvious change to replace subplot with figure;
figure; % Bring up an empty, new figure window.
imshow(grayImage); % Show original image
figure; % Bring up an empty, new figure window.
imshow(medianImage); % Show median filtered image
figure; % Bring up an empty, new figure window.
imshow(equalizedImage); % Show histogram equalized image

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!