Re: Rookie having problems with some filter code. Any help?




Don Bruder wrote:
> Hi folks.
> As the subject line says, I'm a rookie when it comes to image
> processing. I've stumbled onto a few resources online, most notably
> Frederic Patin's paper titled "An Introduction to Digital Image
> Processing" (available at
> <http://www.gamedev.net/reference/programming/features/imageproc/> as of
> the time I write this), and that's given me a lot of the background info
> I need to hack together some basic image-handling routines, but I'm
> having troubles with the results coming out of them - Quite possibly due
> to the fact that I'm such a total greenhorn when it comes to writing
> code to do digital image processing.
>
> I'm not sure if the problems I'm having stem from me being so green at
> the subject, one or more errors in Frederic's paper and/or example code,
> artifacts of converting his code (originally written to target Windows
> by way of a library called "Allegro 4.0") so it can run on a Macintosh,
> my improperly "replacing" some of the Allegro routines with Mac-centric
> versions, a combination of all these factors, or something completely
> off the wall, but whatever the cause, it's clear to anyone taking even
> the most casual glance at the results that my code is failing miserably.
>
> The code in question (commented to the point of ridiculousness for this
> post, since I haven't got a clue who might read it and wonder what on
> earth it's trying to do) as well as a "raw" image and the results of
> shoving that image through my attempt at a matrix-convolution based
> sharpness filter, plus a link to Frederic's paper, can be seen here:
> <http://www.sonic.net/~dakidd/Filterproblems.html>
>
> If any of you have any suggestions for me as to how/why things are going
> bad, and/or how to fix them, I'd be thrilled to death to hear from you,
> either here on the group, or via email. (Just pay attention to my
> anti-spam measures, as noted in my .sig, if you try to relpy to me via
> email.)
>
> I'd also welcome any pointers to more and/or better info on coding
> digital image processing stuff, if anyone would care to point me in the
> right direction. (Please... Spare me the "google it" - I've been wearing
> out my eyeballs trying to figure out what is and isn't relevant in the
> literally millions of results google hands me)
>
> At this point, I just plain don't care how slow/inefficient/etc the code
> I'm working with may be - I can worry about optimizing it later - AFTER
> I've gotten it to the point where it's properly functional. I'm
> currently MUCH more interested in getting basic correct functionality
> out of it than any attempt at making it "the fastest, bestest, greatest
> filter ever written".
>
> Thanks in advance for any assistance you might be able to provide!

There's a lot more there than image processing.

1. For a start change

int sharpen_filter[sharp_w][sharp_h]={
{ 0,-1, 0},
{-1, 5,-1},
{ 0,-1, 0}
};

to

int sharpen_filter[sharp_w][sharp_h]={
{ 0,0, 0},
{0, 1,0},
{ 0,0, 0}
};

and you the output and input should be identical.

2. Print some numbers (a few, a very few) of in and out -- print the
first ten pixels of input and output of the tenth line in the image and
let us see that.

3. Just guessing, you are extracting 8-bit rs, gs and bs from the Color
pixel? And then constructing a Color pixel from the filtered result?

What is 0*0 -1*0 +0*0 -1*0 + 5* 200 -1*0, ...? Does it fit into eight
bits? If that is the case, I don't think 'Normalizer' is of much
assistance; it should be 1; incidentally, did you ever initialise it
before the summation?

Unless you know what you are doing, do image calculations in float or
double and *then* normalise and convert back to whatever.

Best regards,

Jon C.

.



Relevant Pages

  • Re: Double hires mode color artifacts
    ... expect of an Apple II, given its resolution and color limitations. ... essentially no change after the window had filled with 14 "dots". ... pixel on host pixel boundaries. ... A filter of 4 bit width in hires should be already sufficent for that. ...
    (comp.sys.apple2)
  • Re: filtering specific pixels
    ... >>> but the resultant image from the canny filter is a binary ... >>> on those pixels only in my original image, ... >> What we are doing here is any pixel which is far away from your ...
    (comp.soft-sys.matlab)
  • Re: illumination elimination
    ... The theory - Each pixel in your V plane or monochrome image ... Take your log image, and apply the fftfunction to it, apply the ... Read your filter into Matlab using imread, ... If you started life with a colour image reform your HSV structure ...
    (comp.soft-sys.matlab)
  • Re: Fundamental Image Processing Question
    ... One definition of "perfect" is point sampling after low-pass filtering. ... cannot be represented accurately at this pixel density, ... you take your source image and convolve with a filter ... that has a sharp cutoff above 0.5 cycles/pixels, ...
    (sci.image.processing)
  • Re: Deconvolution of Sensor Anti-Alias filter?
    ... shift the image by exactly 1 pixel) is absolutely useless. ... is a much more convincing argument than calculating cosine at some ... shift the digital image by 1 pixel, ...
    (rec.photo.digital)