style
July 2nd, 2007, 06:27 AM
Hello,
I do image processing on bitmaps. I have a question about edge conditions.
For example I use diffrent masks:
1,1,1
1,1,1
1,1,1
or
0,1,0
0,1,0
0,1,0
or
1,1,1,1,1
1,1,1,1,1
1,1,1,1,1
1,1,1,1,1
1,1,1,1,1
and I have a problem with defining edge conditions of filtration. And I would like to ask: what edge conditions should I define/determine?
Boris K K
July 2nd, 2007, 11:23 AM
I suppose by 'edge conditions' you mean how to calculate pixels, for which the matrix needs data from outside the boundaries of the original image.
You have to choose between several options:
Ignore matrix elements, which do not correspond to existing pixels and change the normalization (the divisor) according to the elements actually used.
Use the value of the nearest existing pixel.
Wrap (use pixels from the other edge of the bitmap)
Use for missing pixels the average value for the whole image...
style
July 2nd, 2007, 12:09 PM
thank you, these informations are very useful.
style
July 9th, 2007, 07:45 AM
I suppose by 'edge conditions' you mean how to calculate pixels, for which the matrix needs data from outside the boundaries of the original image.
You have to choose between several options:
Ignore matrix elements, which do not correspond to existing pixels and change the normalization (the divisor) according to the elements actually used.
Use the value of the nearest existing pixel.
Wrap (use pixels from the other edge of the bitmap)
Use for missing pixels the average value for the whole image...
What do you think about which option is the best? and which option should I use?
Boris K K
July 9th, 2007, 09:33 AM
I would use #2 and #1.
I believe #1 is OK if all matrix elements are non-negative, but may cause some artifacting near the borders with sharpening kernels (containing negative elements). Then #2 may be a better choice. This is just a guess, though.
Also, #2 is easier to optimize for speed if you enlarge the original picture with (int) (matrix_size / 2) pixels border around each side and initialize the border pixels with the colors of the nearest "real" pixel. Then you can compute the result without the need to check for any boundary conditions.