It is currently Thu Oct 19, 2017 9:44 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Sepia tunes?
PostPosted: Sun Oct 04, 2015 3:25 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
According to this page, sepia tunes should use the following formula.
Code:
outputRed = (inputRed * .393) + (inputGreen *.769) + (inputBlue * .189)
outputGreen = (inputRed * .349) + (inputGreen *.686) + (inputBlue * .168)
outputBlue = (inputRed * .272) + (inputGreen *.534) + (inputBlue * .131)

But instead of sepia, I'm getting... this. :( Why???


Attachments:
Rockman 5 - Blues no Wana! (J) 004.bmp
Rockman 5 - Blues no Wana! (J) 004.bmp [ 900.05 KiB | Viewed 1719 times ]
Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Sun Oct 04, 2015 3:41 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6280
Location: Seattle
That matrix of parameters isn't singular. Looks like rounding error, though.
Code:
>> [.393 .769 .189; .349 .686 .168; .272 .534 .131]^-1
ans =

   1.2727e+03   1.5455e+03  -3.8182e+03
  -1.9008e+02   6.1983e+02  -5.2066e+02
  -1.8678e+03  -5.7355e+03   1.0058e+04


Is there any chance you typoed or transposed one of the numbers?

You probably want to convert to greyscale and then use a simple colormap to convert that to sepiatone (White down through a grayish color, then through brown, then black)


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Sun Oct 04, 2015 4:21 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19101
Location: NE Indiana, USA (NTSC)
If the effect you're aiming for is less "real is brown" and more "the past is brown", this should approximate sepia for an NES picture:
  • Map 20 and 30-3C to 37
  • Map 10 and 21-2C to 27
  • Map 00 and 11-1C to 17
  • Map xD-xF and 01-0C to 07


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Sun Oct 04, 2015 4:30 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5718
Location: Canada
Quote:
These specific values are the values for sepia tone that are recommended by Microsoft.

What an odd statement. Is Microsoft was some kind of sepia authority now?

If you want zero blue in your sepia conversion, you should create your own matrix that completely desaturates the image to remove input colour influences on the output. The one you're using only partially desaturates.

I think lidnariq suggested what you really want. Convert to greyscale first, then some sort of filter/map to convert to brownish colours. (You might be able to do with with a single matrix, but you'll probably want to work it out in steps first, at least.)


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Sun Oct 04, 2015 5:32 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
Fine, so I'm using my own current method for monochromes. :)

Code:
newValue_R = (brightness * $70) >> 7
newValue_G = (brightness * $42) >> 7
newValue_B = (brightness * $14) >> 7

The sepia hex triplet (from wikipedia) is $70$42$14.
Result below.


Attachments:
Rockman 5 - Blues no Wana! (J) 005.bmp
Rockman 5 - Blues no Wana! (J) 005.bmp [ 900.05 KiB | Viewed 1683 times ]
Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Sun Oct 04, 2015 6:07 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6280
Location: Seattle
Which looks more like an amber CRT than actual sepiatone, because sepiatone (a silver sulfide gelatin print) isn't a single line in RGB space. It's formed by producing a thicker and thicker layer of Ag₂S, which for a given amount W of material, blocks X% of blue light, Y% of green light, and Z% of red light. So it's almost a straight line in HSL (but not in HSV)


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Sun Oct 04, 2015 6:57 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
lidnariq wrote:
Which looks more like an amber CRT than actual sepiatone, because sepiatone (a silver sulfide gelatin print) isn't a single line in RGB space. It's formed by producing a thicker and thicker layer of Ag₂S, which for a given amount W of material, blocks X% of blue light, Y% of green light, and Z% of red light. So it's almost a straight line in HSL (but not in HSV)


But that's not "converting to grayscale firstly". How am I supposed to do with RGB values?
From this alternative page I've found "43.9% red, 25.9% green and 7.8% blue". With a "small kick of x2", I got the following result below.


Attachments:
Rockman 5 - Blues no Wana! (J) 006.bmp
Rockman 5 - Blues no Wana! (J) 006.bmp [ 900.05 KiB | Viewed 1660 times ]
Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Sun Oct 04, 2015 7:16 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19101
Location: NE Indiana, USA (NTSC)
Try this nonlinear formula and show us how it looks:

Y = .3R+.6G+.1B
Gnew = Y
Bnew = (Y * Y / Ymax + Y) / 2
Rnew = 3 * Ymax - (Gnew + Bnew)

where Ymax is 1.0 or 255 or whatever for your particular color space


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 8:06 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
Code:
   int Y = (p->red * .3) + (p->green * .6) + (p->blue *.1);
   int Gnew = Y;
   int Bnew = (Y * Y / 255 + Y) / 2;
   int Rnew = 3 * 255 - (Gnew + Bnew);
   p->red = Rnew; p->green = Gnew; p->blue = Bnew;
   if(p->red > 255) p->red = 255;
   if(p->green > 255) p->green = 255;
   if(p->blue > 255) p->blue = 255;

Reddish. :(
Is something wrong?


Attachments:
Rockman 5 - Blues no Wana! (J) 007.bmp
Rockman 5 - Blues no Wana! (J) 007.bmp [ 900.05 KiB | Viewed 1618 times ]
Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 8:21 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19101
Location: NE Indiana, USA (NTSC)
I typed that off the top of my head without testing, as I was on a rare break from crunch time on my present project.

Try newR = Y, newG = Y, and newB as before.
Or try newR = Y, newB as before, and newG = (newR + newB) / 2.
Or try newR = Y/2 + 128, newG = Y/2 + 64, newB = Y/2.

Or how does it look with my mapping everything to column 7?


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 10:54 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6280
Location: Seattle
All of those won't have the desired effect because they are straight lines in RGB.

Convert the input to grayscale, use the grayscale volume as L in HSL (with H≈orange, S≈50%), convert back to RGB.

Another thought: Grayscale, then try using different gammas for the different channels. Perhaps R=2.2, G=1.1, B=.55? Produces this:
Attachment:
rgamma_2.2_ggamma_1.1_bgamma_0.55.png
rgamma_2.2_ggamma_1.1_bgamma_0.55.png [ 1.13 KiB | Viewed 1594 times ]


Anything with Rgamma = 2Ggamma = 4Bgamma looks not unreasonable, upon briefly playing with it.


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 1:39 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
My method of grayscale takes the brightness level and uses it to generate the RGB values for sepia.
I don't know... that red * 2.2 seems to generate a couple of $FFs.
Anyway, result below.


Attachments:
Rockman 5 - Blues no Wana! (J) 008.bmp
Rockman 5 - Blues no Wana! (J) 008.bmp [ 900.05 KiB | Viewed 1574 times ]
Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 2:06 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5718
Location: Canada
Gamma means a power/exponent operation. In this case I think the suggestion was:

R ^ (1 / 2.2)
G ^ (1 / 1.1)
B ^ (1 / 0.55)


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 2:32 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3064
Location: Brazil
rainwarrior wrote:
Gamma means a power/exponent operation. In this case I think the suggestion was:

R ^ (1 / 2.2)
G ^ (1 / 1.1)
B ^ (1 / 0.55)


Sorry for the request, but mind you to write a C code for it? Mine's generating grayscale only.


Top
 Profile  
 
 Post subject: Re: Sepia tunes?
PostPosted: Mon Oct 05, 2015 2:35 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5718
Location: Canada
Code:
float r; // input colours in the range 0-1

#include <math.h>
r = pow(r, 1.0 / 2.2); // R ^ (1 / 2.2)

// output r is still in the range 0-1


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group