Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
image Smoothing

Subject: image Smoothing

From: Snow White

Date: 9 Apr, 2009 11:51:01

Message: 1 of 9

Hello,

I want to apply the median filter to an image for smoothing. Here is the error that i get.. below is the code that i have written for smoothing..

??? Function ORDFILT2 expected its first input, A, to be two-dimensional.

Error in ==> ordfilt2>ParseInputs at 135
  iptcheckinput(A, {'numeric','logical'}, {'2d','real'}, mfilename, 'A', 1);

Error in ==> ordfilt2 at 51
[A,order,domain,s,padopt,msg] = ParseInputs(varargin{:});

Error in ==> medfilt2 at 53
    b = ordfilt2(a, order, domain, padopt);

Error in ==> refractive_index_estimation at 37
            img = medfilt2(smoothie,[3 3]);

fname=imread(f_name);
            imwrite(fname,e);
            smoothie=imread(e);
            
            img = medfilt2(smoothie,[3 3]);

Bye

Subject: image Smoothing

From: Bruno Luong

Date: 9 Apr, 2009 12:01:03

Message: 2 of 9

"Snow White" <gulesaman@gmail.com> wrote in message <grknf5$6h2$1@fred.mathworks.com>...
>
> ??? Function ORDFILT2 expected its first input, A, to be two-dimensional.
>

And how many dimensions has your image after using imread?

Bruno

Subject: image Smoothing

From: John D'Errico

Date: 9 Apr, 2009 12:13:01

Message: 3 of 9

"Snow White" <gulesaman@gmail.com> wrote in message <grknf5$6h2$1@fred.mathworks.com>...
> Hello,
>
> I want to apply the median filter to an image for smoothing. Here is the error that i get.. below is the code that i have written for smoothing..
>
> ??? Function ORDFILT2 expected its first input, A, to be two-dimensional.
>
> Error in ==> ordfilt2>ParseInputs at 135
> iptcheckinput(A, {'numeric','logical'}, {'2d','real'}, mfilename, 'A', 1);
>
> Error in ==> ordfilt2 at 51
> [A,order,domain,s,padopt,msg] = ParseInputs(varargin{:});
>
> Error in ==> medfilt2 at 53
> b = ordfilt2(a, order, domain, padopt);
>
> Error in ==> refractive_index_estimation at 37
> img = medfilt2(smoothie,[3 3]);
>
> fname=imread(f_name);
> imwrite(fname,e);
> smoothie=imread(e);
>
> img = medfilt2(smoothie,[3 3]);
>
> Bye

The error message seems fairly clear. It expects A to be
a two dimensional array. It was not.

So then I read the help for medfilt2. It appears that
medfilt2 is designed to work on TWO dimensional arrays.

Just smooth one plane of the image at a time.

John


John

Subject: image Smoothing

From: Snow White

Date: 9 Apr, 2009 14:57:01

Message: 4 of 9

2 dimensional i guess... images are two dimensional no?

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <grko1v$fg3$1@fred.mathworks.com>...
> "Snow White" <gulesaman@gmail.com> wrote in message <grknf5$6h2$1@fred.mathworks.com>...
> >
> > ??? Function ORDFILT2 expected its first input, A, to be two-dimensional.
> >
>
> And how many dimensions has your image after using imread?
>
> Bruno

Subject: image Smoothing

From: Snow White

Date: 9 Apr, 2009 14:58:01

Message: 5 of 9

It is one plane its a grey level image

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <grkood$49h$1@fred.mathworks.com>...
> "Snow White" <gulesaman@gmail.com> wrote in message <grknf5$6h2$1@fred.mathworks.com>...
> > Hello,
> >
> > I want to apply the median filter to an image for smoothing. Here is the error that i get.. below is the code that i have written for smoothing..
> >
> > ??? Function ORDFILT2 expected its first input, A, to be two-dimensional.
> >
> > Error in ==> ordfilt2>ParseInputs at 135
> > iptcheckinput(A, {'numeric','logical'}, {'2d','real'}, mfilename, 'A', 1);
> >
> > Error in ==> ordfilt2 at 51
> > [A,order,domain,s,padopt,msg] = ParseInputs(varargin{:});
> >
> > Error in ==> medfilt2 at 53
> > b = ordfilt2(a, order, domain, padopt);
> >
> > Error in ==> refractive_index_estimation at 37
> > img = medfilt2(smoothie,[3 3]);
> >
> > fname=imread(f_name);
> > imwrite(fname,e);
> > smoothie=imread(e);
> >
> > img = medfilt2(smoothie,[3 3]);
> >
> > Bye
>
> The error message seems fairly clear. It expects A to be
> a two dimensional array. It was not.
>
> So then I read the help for medfilt2. It appears that
> medfilt2 is designed to work on TWO dimensional arrays.
>
> Just smooth one plane of the image at a time.
>
> John
>
>
> John

Subject: image Smoothing

From: Bruno Luong

Date: 9 Apr, 2009 15:48:01

Message: 6 of 9

"Snow White" <gulesaman@gmail.com> wrote in message <grl2bt$5ua$1@fred.mathworks.com>...
> 2 dimensional i guess... images are two dimensional no?

Please don't guess, use NDIMS or SIZE to figure out.

Do you know what is RGB images?

Bruno

Subject: image Smoothing

From: John D'Errico

Date: 9 Apr, 2009 15:49:01

Message: 7 of 9

"Snow White" <gulesaman@gmail.com> wrote in message <grl2bt$5ua$1@fred.mathworks.com>...
> 2 dimensional i guess... images are two dimensional no?
>
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <grko1v$fg3$1@fred.mathworks.com>...
> > "Snow White" <gulesaman@gmail.com> wrote in message <grknf5$6h2$1@fred.mathworks.com>...
> > >
> > > ??? Function ORDFILT2 expected its first input, A, to be two-dimensional.
> > >
> >
> > And how many dimensions has your image after using imread?
> >
> > Bruno

An image is usually a 3 dimensional array,
containing planes for red, green, and blue.

Check the size of your image array.

Even if your image is a gray scale image, it
may still have three planes.

John

Subject: image Smoothing

From: Snow White

Date: 9 Apr, 2009 16:07:01

Message: 8 of 9

hi

ndims gives me 2! so it is a 2 dimensional image..

n yes i know abt RGB

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <grl5dd$b9t$1@fred.mathworks.com>...
> "Snow White" <gulesaman@gmail.com> wrote in message <grl2bt$5ua$1@fred.mathworks.com>...
> > 2 dimensional i guess... images are two dimensional no?
> >
> > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <grko1v$fg3$1@fred.mathworks.com>...
> > > "Snow White" <gulesaman@gmail.com> wrote in message <grknf5$6h2$1@fred.mathworks.com>...
> > > >
> > > > ??? Function ORDFILT2 expected its first input, A, to be two-dimensional.
> > > >
> > >
> > > And how many dimensions has your image after using imread?
> > >
> > > Bruno
>
> An image is usually a 3 dimensional array,
> containing planes for red, green, and blue.
>
> Check the size of your image array.
>
> Even if your image is a gray scale image, it
> may still have three planes.
>
> John

Subject: image Smoothing

From: Snow White

Date: 9 Apr, 2009 16:10:03

Message: 9 of 9

smooth=imread(e);
            n = ndims(e)

if i check the dimensions of e i get 2 while for smooth it gives me 3 :s

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <grl5dd$b9t$1@fred.mathworks.com>...
> "Snow White" <gulesaman@gmail.com> wrote in message <grl2bt$5ua$1@fred.mathworks.com>...
> > 2 dimensional i guess... images are two dimensional no?
> >
> > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <grko1v$fg3$1@fred.mathworks.com>...
> > > "Snow White" <gulesaman@gmail.com> wrote in message <grknf5$6h2$1@fred.mathworks.com>...
> > > >
> > > > ??? Function ORDFILT2 expected its first input, A, to be two-dimensional.
> > > >
> > >
> > > And how many dimensions has your image after using imread?
> > >
> > > Bruno
>
> An image is usually a 3 dimensional array,
> containing planes for red, green, and blue.
>
> Check the size of your image array.
>
> Even if your image is a gray scale image, it
> may still have three planes.
>
> John

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us