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

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

if true
% code
endclear;
clc;
pic=imread('C:\masters courses\applications of dsp\project2\GW_1200.jpg');
subplot(3,3,1);
imshow(pic);
title('original image');
m=medfilt2(pic);
subplot(3,3,2);
imshow(m);
title('Median Fileter of image');
a10=histeq(pic);
subplot(3,3,3);
imshow(a10);
title('Histogram equalization of image');
the above one is my program
when i was pasting my program in the box it was ok but in the preview its coming like that and i am not able to change that. i am sorry
You are. Edit the post, highlight the code (and ONLY the code), then click {}Code.
see this is the first time i am using matlab, so i doesnt know al these things
Did you try my Answer? It should fix the problem.
i had done that you can check the code now
Sorry, I don't see in your code where you area extracting one color channel or are calling rgb2gray(). Where is that?
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

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

Attach GW_1200.jpg so I can try your code, which looks like it should work.
It worked fine. I didn't have to do anything. I did fancy it up a bit though. Run the attached code to get the figure below.
Can you mark the answer as Accepted then? Thanks in advance.
Hi, i have similar problem and using your code, it works perfectly well. Nice one, kudos to you. Pls, in mine, i am trying to have the images i.e the gray image, the median filtered image, and the histogram equalized image in seperate window, i tried using the command "figure", but i am not getting a satisfactory result. Can you help pls? Will appreciate it.
Try this:
hFig = figure; % Bring up an empty, new figure window.
subplot(1, 3, 1); % Bring up image on the left
imshow(grayImage); % Show original image
hFig.WindowState = 'maximized'; % Maximize figure window.
subplot(1, 3, 2); % Bring up image on the middle
imshow(medianImage); % Show median filtered image
subplot(1, 3, 3); % Bring up image on the right
imshow(equalizedImage); % Show histogram equalized image
Modify to use your image variable names. Or use subplot(3, 1, n) if you want images displayed vertically instead of horizontally.
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
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)

Categories

Find more on Images 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!