hi everybody,
i want to develop a application, that opens an image (JPG or whatever)
and applies an sepia-photo-filter on it, befor it saves the changed
image into a file with another name.
i have no problem in opening the image, gaining the RGB-values of any
pixel and save the image afterwards. my problem is just, that i don't
know, how to program such a filter.
it should look like the effect, i have in my Photoshop CS 2, under
Image/Adjustments/Photo Filter (for german users: Bild/Anpassen/
Fotofilter). of course i can draw an transparent brown rectangle on my
image, but this doesn't look like the filter of photoshop and above
all it doesn't look that good.
i tried to read the RGB-value of a pixel, transform it into HSB-color
model and change the pixel-data. first by setting the hue to the value
of the brown-tone, but brown is just an orange-hue with something like
50% saturation and 50% brightness. after recognizing this, i tried to
set the hue to the the hue of the brown, that i want, and multiplied
the saturation and the brightness of my brown with the values of the
pixel. this ends in a very dark version of my image, when i just
multiply the saturation-values its brighter, but also not the effect i
seek. by the way, multiplying the values worked because my HSB-values
are all between 0.0 and 1.0. my second attempt was to transform the
RGB-values of the pixel into Lab, because i've read that photoshop
takes this as base of all transformations. then i tried to set the a-
and the b-value to the one of my brown-tone. ... ... ... well ... this
doesn't end well. :-(
has somebody an idea how this can be done? i would appreciate any help
here.
you don't have to write much. i just need the mathematic operations,
that i have to perform on my image (maybe with a hint in which color-
model i have to work on this) or just a link to a proper solution.
many thanks :-)
wayne
|
|
0
|
|
|
|
Reply
|
info
|
7/19/2007 2:00:10 PM |
|
On Thu, 19 Jul 2007 07:00:10 -0700, info@belwin.de wrote:
>hi everybody,
>
>i want to develop a application, that opens an image (JPG or whatever)
>and applies an sepia-photo-filter on it, befor it saves the changed
>image into a file with another name.
>
>i have no problem in opening the image, gaining the RGB-values of any
>pixel and save the image afterwards. my problem is just, that i don't
>know, how to program such a filter.
>
>it should look like the effect, i have in my Photoshop CS 2, under
>Image/Adjustments/Photo Filter (for german users: Bild/Anpassen/
>Fotofilter). of course i can draw an transparent brown rectangle on my
>image, but this doesn't look like the filter of photoshop and above
>all it doesn't look that good.
>
>i tried to read the RGB-value of a pixel, transform it into HSB-color
>model and change the pixel-data. first by setting the hue to the value
>of the brown-tone, but brown is just an orange-hue with something like
>50% saturation and 50% brightness. after recognizing this, i tried to
>set the hue to the the hue of the brown, that i want, and multiplied
>the saturation and the brightness of my brown with the values of the
>pixel. this ends in a very dark version of my image, when i just
>multiply the saturation-values its brighter, but also not the effect i
>seek. by the way, multiplying the values worked because my HSB-values
>are all between 0.0 and 1.0. my second attempt was to transform the
>RGB-values of the pixel into Lab, because i've read that photoshop
>takes this as base of all transformations. then i tried to set the a-
>and the b-value to the one of my brown-tone. ... ... ... well ... this
>doesn't end well. :-(
>
>has somebody an idea how this can be done? i would appreciate any help
>here.
>
>you don't have to write much. i just need the mathematic operations,
>that i have to perform on my image (maybe with a hint in which color-
>model i have to work on this) or just a link to a proper solution.
>
>many thanks :-)
>
>wayne
You can convert to greyscale by setting the RGB components of each
pixel to the average of all three:
foreach pixel in image do
grey = (pixel.red + pixel.green + pixel.blue) / 3
pixel.red = grey
pixel.green = grey
pixel.blue = grey
end foreach
Once you have the picture in greyscale you can try ways of adding
sepia. My first attempt was:
foreach pixel in image do
grey = (pixel.red + pixel.green + pixel.blue) / 3
pixel.red = min(3 * grey, 255)
pixel.green = min(2 * grey, 255)
pixel.blue = grey
end foreach
Which was far from perfect. No doubt you can do better.
rossum
|
|
0
|
|
|
|
Reply
|
rossum
|
7/19/2007 3:07:49 PM
|
|
"rossum" <rossum48@coldmail.com> wrote in message
news:uptu93haj06capgjpoifv1phtm6dmmeis0@4ax.com...
> On Thu, 19 Jul 2007 07:00:10 -0700, info@belwin.de wrote:
> >i want to develop a application, that opens an image (JPG or whatever)
> >and applies an sepia-photo-filter on it, befor it saves the changed
> >image into a file with another name.
[...]
> You can convert to greyscale by setting the RGB components of each
> pixel to the average of all three:
>
> foreach pixel in image do
> grey = (pixel.red + pixel.green + pixel.blue) / 3 (<----- eek!)
> pixel.red = grey
> pixel.green = grey
> pixel.blue = grey
> end foreach
If you have Photoshop, why not create a rainbow gradient and apply the filter;
then compare before and after pixel values.
I'm quite sure the Gimp has a sepia filter as well, and if that's the case, take
it from their freely available source.
[Jw]
|
|
0
|
|
|
|
Reply
|
Jongware
|
7/19/2007 8:15:43 PM
|
|
[Jongware] wrote:
> "rossum" <rossum48@coldmail.com> wrote in message
> news:uptu93haj06capgjpoifv1phtm6dmmeis0@4ax.com...
>
>>On Thu, 19 Jul 2007 07:00:10 -0700, info@belwin.de wrote:
>>
>>>i want to develop a application, that opens an image (JPG or whatever)
>>>and applies an sepia-photo-filter on it, befor it saves the changed
>>>image into a file with another name.
>
> [...]
>
>>You can convert to greyscale by setting the RGB components of each
>>pixel to the average of all three:
>>
>> foreach pixel in image do
>> grey = (pixel.red + pixel.green + pixel.blue) / 3 (<----- eek!)
>> pixel.red = grey
>> pixel.green = grey
>> pixel.blue = grey
>> end foreach
>
>
> If you have Photoshop, why not create a rainbow gradient and apply the filter;
> then compare before and after pixel values.
> I'm quite sure the Gimp has a sepia filter as well, and if that's the case, take
> it from their freely available source.
In that case don't bother writing a C program. Gimp is scriptable with
Lisp and Perl, so some small script will be fine.
Christian
|
|
0
|
|
|
|
Reply
|
Christian
|
7/20/2007 9:26:53 AM
|
|
|
3 Replies
169 Views
(page loaded in 0.067 seconds)
|