User Controls
Algorithm for photo enhancement
-
2015-10-09 at 8:14 AM UTCThis may seem like a strange question and I'm not sure if I'll get any responses, but I am looking to make a simple program(most likely JAVA) that'll change a photo I have, into a similar photo but with an enhancement. I have never done any graphic programming aside from toying around with existing OCR code attempting to bypass CAPTCHA.
In a nutshell, I want to change certain parts of the photo, based of the darkness/lightness, to either become a diagonal line at a 45 degree angle(each way depending on the shade) or a checkered box patterned. These three things(each one of the diagonal lines at a 45 degree angle, for both ways, and the checkered box pattern), would all be based on the lightness/darkness OR maybe even the specific color(I would want to try both).
One more thing that this will all need, will be that either the diagonal lines, or checkered boxed areas, will have to alternate line by line, one darker than the original, the next lighter, the next darker, the next lighter...
I know exactly how many pixels wide I need the lines to become in the specific photo, but I need to write up a specific algorithm for this process because all of this photo will need to mend into one. Meaning, that the lines, regardless of their direction or pattern, will need to line up specifically to the amount of pixels that I need them to be.
I was curious if any of you have any experience doing anything like this? -
2015-10-09 at 9:32 AM UTCCan't say i do, wouldn't there be software out there for this purpose though?
-
2015-10-09 at 7:25 PM UTCI suppose you could generate images of the diagonal line and checker box patterns the same size as your source image, then analyze your source image and for each pixel that should be patterned, sample the corresponding pixel from the pattern image and copy the pixel to the source image.
As for calculating the darkness/lightness of a pixel, here are some algorithms. Check out the first answer:
https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
OpenGL is well suited for this sort of stuff. It would be very fast, too, due to all the calculations being performed on the GPU. -
2015-10-09 at 11:17 PM UTC
I suppose you could generate images of the diagonal line and checker box patterns the same size as your source image, then analyze your source image and for each pixel that should be patterned, sample the corresponding pixel from the pattern image and copy the pixel to the source image.
Right now this is kind of how I'm doing it. I basically make a duplicate of the image so that I have two, then put the diagonal lines over each one but so that they are 'off-set', then I make one image lighter and the other darker, then I combine both. When printed out, it's not noticeable at a distance, but up close you can see the alternating lines. I haven't done this with bot diagonals or the 'checkered areas'(which aren't really checked, they are more like what a tic-tac-toe grid whould look like it the lines that made it were the same size as the inner squares).
Thanks for answering. -
2015-10-10 at 2:46 AM UTCSo is the decision to apply each of these transformations based on the total brightness of the image or do you like subdivide into regions and apply based on local brightness?
-
2015-10-10 at 4:54 PM UTC
So is the decision to apply each of these transformations based on the total brightness of the image or do you like subdivide into regions and apply based on local brightness?
Subdiving regions was what I was going to do but when I found out how to calculate the luminance average of the whole area, I found out that my printer wont print the checkered areas well enough. So Im tossing the project. -
2015-10-11 at 7:48 AM UTCI think I'm going to do it just for fun and mess with it a little bit. There was something I didn't try and think that could work. Please stand by.
-
2015-10-14 at 6:24 AM UTCBout 250 lines of code later and I'm mostly finished.
This is what I've been talking about, except that my shading is turning bluish in the darkest areas. Anyways, the darker areas have the 'checkered' boxes, the lighter area's have lines going from left to right, and the lightest areas have lines going right to left. All of the lines align up correctly and the size can be easily changed.
Original image...
http://www.angelfire.com/un/sbt/images/image0.jpg
http://www.angelfire.com/un/sbt/images/OrigImg.html
Enhanced...
http://www.angelfire.com/un/sbt/images/image4.jpg
http://www.angelfire.com/un/sbt/images/EnhaImg.html
Finished a while back but forgot to update...
http://www.angelfire.com/un/sbt/images/Final.html