Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update p_box3x3.c #76

Closed
wants to merge 4 commits into from
Closed

Update p_box3x3.c #76

wants to merge 4 commits into from

Conversation

twocs
Copy link
Contributor

@twocs twocs commented Jun 4, 2015

Fix stopping conditions of previous edit. Simplified stopping conditions.

twocs and others added 4 commits June 5, 2015 00:39
Fix stopping conditions of previous edit. Simplified stopping conditions.
Computing address of a pointer outside array bounds is undefined, so don't increment *px in the last cell. Also it's unnecessary.
input image:    output image
|1 1 1 1|          |0 0 0 0| 
|1 1 1 1|          |0 1 1 0| 
|1 1 1 1|          |0 1 1 0| 
|1 1 1 1|          |0 0 0 0| 

Note that here we do not assign 0 to the outside cells in the output image.
@olajep
Copy link
Member

olajep commented Jun 12, 2015

Looks right to me.
We need to write a test case for this at some point

One remaining question mark for me is how the algo should behave around the edges. Take the upper leftmost pixel @ (x,y)=(0,0) for example. Shouldn't we apply the filter there too, but only for its neighboring pixels that are actually in the image?
out(0,0) = mean((0,0) (0,1) (1,0) (1,1))

ping @aolofsson

@twocs
Copy link
Contributor Author

twocs commented Jun 13, 2015

The most basic image filter will simply disregard the edges rather than performing some alternate calculations, as is done here. Note that input dimension: rows x cols. Output image dimension: (rows - 2) x (cols - 2).

If you want to apply the filter in the corners, there are many options but almost all would require different output image dimensions than current. Common ones treat all outside pixels as zero, the same as the nearest pixel, or as an average of nearby pixels.

Some discussion here: #106

@twocs
Copy link
Contributor Author

twocs commented May 27, 2024

Very old merge request.

@twocs twocs closed this May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants