Image Processing Mag and Phase Spectrum of Sobel, Roberts Mask [closed]

How to find the Magnitude and Phase Spectrum of Sobel, Roberts etc. etc. Mask of Image Processing using MATHEMATICA 9.0 platform....

closed as unclear what you're asking by user21, Yves Klett, Jens, Artes, m_goldbergAug 8 '13 at 12:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Would you min detailing your question? – Yves Klett Aug 8 '13 at 5:56
• I agree the question is unclear. – Jens Aug 8 '13 at 6:11

You can find most of the definitions for these filters by googling, and once you know the definition it can be put directly into the GradientFilter command using the Method option:

im = ExampleData[{"TestImage", "JellyBeans"}];


Sobel

GradientFilter[im,
Method -> {{{1, 0, -1}, {2, 0, -2}, {1, 0, -1}}/
4., {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}}/4.}]


Roberts

GradientFilter[im, Method -> {{{0, 1}, {-1, 0}}, {{1, 0}, {0, -1}}}]


Prewitt

GradientFilter[im,
Method -> {{{1, 0, -1}, {1, 0, -1}, {1, 0, -1}}, {{-1, -1, -1}, {0,
0, 0}, {1, 1, 1}}}]


Edit: phase information

To get the phase of the gradient, one could use ImageConvolve, and if you want the syntax to be analogous to the above GradientFilter, a function could be defined like this:

Options[phaseFilter] = {
Method -> {{{1, 0, -1}, {1, 0, -1}, {1, 0, -1}}, {{-1, -1, -1}, {0,
0, 0}, {1, 1, 1}}}
};

phaseFilter[im_, OptionsPattern[]] :=
Module[{method = OptionValue[Method]},
Image@Rescale@
MapThread[ArcTan, ImageData[ImageConvolve[im, #]] & /@ method]
]

phaseFilter[im, Method -> {{{0, 1}, {-1, 0}}, {{1, 0}, {0, -1}}}]


The default method is the Prewitt filter (if you don't specify any Method explicitly).

This does the convolution in each color channel. It may make more sense to first convert to grayscale:

phaseFilter[ColorConvert[im, "Graylevel"],
Method -> {{{0, 1}, {-1, 0}}, {{1, 0}, {0, -1}}}]


• Ok its nice information, but still I m not getting.. because I want to find the Fourier Spectrum of Sobel, Roberts, etc. Mask, and then MULTIPLY with the Fourier Spectrum of the Input Image, to get the Output Image after Inverse Fourier Transformation. – user8727 Aug 8 '13 at 5:29
• What you're describing is just an application of the convolution theorem. It is made unnecessary if you do the convolution directly using ImageConvolve. What I did in my answer is equivalent to what you describe. – Jens Aug 8 '13 at 5:51

You can simply use Fourier to calculate the fourier transform of a filter:

filter = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
(* move anchor to 1/1 and pad to 32x32 *)


and MatrixPlot to show the results:

Row[MatrixPlot[#, ImageSize -> 400] & /@ {Abs[ft], Arg[ft]}]


or any other plotting function you like:

Row[ListPlot3D[#, ImageSize -> 400] & /@ {Abs[ft], Arg[ft]}]


• ThankU very much for Ur time and Reply....One more thing I want to ask is that "The two-dimensional Fractional Fourier Transform" available in the Wolfram Demonstrations is same as Prof. Haldun Ozaktas, Prof. S. C. Pei has established in their Research Papers....or its VERY different..... – user8727 Aug 8 '13 at 6:02
• Looks like you understood what was being asked - I was mislead by the reference to image processing, but all it was seems to be an FT... +1 – Jens Aug 8 '13 at 6:10
• Again sorry for asking the Question about MMA....If one has to MULTPLY two different Magnitude and Phase Spectra both, to get the new Magnitude and Phase Spectra, then which command to use...... – user8727 Aug 8 '13 at 6:23
• @user8727: Not trying to be rude, but you should really get an introductory book about MMA and read it cover to cover. Having to ask basic stuff like "how do I multiply two things" must be annoying for you too, and the resulting answers aren't helpful to anyone else. That's why your questions get closed or downvoted: A Q&A-site like this can't replace a good tutorial, introductory course or book. It's simply the wrong format. I can recommend "Programming in MMA" by Maeder and "Programming with MMA" by Wellin. – Niki Estner Aug 8 '13 at 6:49