Main Page | Report this Page
 
   
Science Forum Index  »  Image Processing Forum  »  interpolation for a color image?...
Page 1 of 3    Goto page 1, 2, 3  Next
Author Message
AE lover...
Posted: Thu May 22, 2008 6:03 am
Guest
Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks
Thomas Richter...
Posted: Thu May 22, 2008 1:29 pm
Guest
AE lover schrieb:
Quote:
Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Interesting idea, and a longer answer.

It depends on what you think your image channels will be, and how to make
use of their correlation. A typical way to do that is to first transform
them to a different color space, for example YUV. The transformation between
YUV (and related other spaces) is linear, and the bilinear interpolation
filter is linear as well, but in a different dimension. This means that
it actually makes *no* difference at all whether you first transform to
YUV, run there a bilinear filter, then transform back, or run the bilinear
filter on RGB itself. The result will be the same. But *only* because
bilinear filtering is linear, and YUV to RGB is a linear transformation.

If you pick a nonlinear color space (say, CIElab) and/or a nonlinear
filter (say, bicubic), things will be not so easy and the results will
be different. Probably not much different, since the purpose of interpolation
filters is to create pixels that are not very different from the surrounding.

Anyhow, if quality is of your concern, I would suggest to use a higher
interpolation filter, bicubic is typically fine.

So long,
Thomas
Martin Leese...
Posted: Fri May 23, 2008 12:13 pm
Guest
AE lover wrote:
Quote:
Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

What interaction? Obviously there is
interaction, but it varies with the content
of the image. Therefore, there cannot be a
one-size-fits-all solution.

--
Regards,
Martin Leese
E-mail: please at (no spam) see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
ImageAnalyst...
Posted: Fri May 23, 2008 3:40 pm
Guest
On May 22, 12:03 pm, AE lover <aelove... at (no spam) gmail.com> wrote:
Quote:
Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

---------------------------------
I think I've seen where you get color artifacts if you do this in RGB
space, especially at edges (where the color changes abruptly). This
is reduced if you interpolate in a different color space such as HSI
(which takes into account interactions, like you say, because the HSI
bands are weighted sums or formulas of RGB.)
http://www.easyrgb.com/index.php?X=MATH

Regards,
ImageAnalyst
Simon Johan...
Posted: Fri May 23, 2008 3:48 pm
Guest
"AE lover" <aelover11 at (no spam) gmail.com> wrote in message
news:2a03e221-19de-4e85-81d1-0b0e3ee4d7e3 at (no spam) k37g2000hsf.googlegroups.com...
Quote:
Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Quaternion convolution?
aruzinsky...
Posted: Sat May 24, 2008 6:14 am
Guest
On May 23, 7:40 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:
Quote:
On May 22, 12:03 pm, AE lover <aelove... at (no spam) gmail.com> wrote:

Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

---------------------------------
I think I've seen where you get color artifacts if you do this in RGB
space, especially at edges (where the color changes abruptly).  This
is reduced if you interpolate in a different color space such as HSI
(which takes into account interactions, like you say, because the HSI
bands are weighted sums or formulas of RGB.)http://www.easyrgb.com/index.php?X=MATH

Regards,
ImageAnalyst

You cannot properly interpolate on the H channel. Suppose you have a
red ( H = 0 degrees ) object against a blue ( H = 240 ) background.
Bilinearly interpolating to the middle you get H = 120 so you will get
a lime green border around the object. Not to mention 0 and 359 are
both red so you can get every other color interpolating within a
completely red region.

I have seen odd instances where changing the RGB gamma to 2.2 (or is
it the reciprocal) produces better results, but in most cases it is
better leave gamma alone.

Thomas Richter already said everything important.
ImageAnalyst...
Posted: Sat May 24, 2008 3:59 pm
Guest
On May 24, 12:14 pm, aruzinsky <aruzin... at (no spam) general-cathexis.com> wrote:
Quote:
On May 23, 7:40 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:





On May 22, 12:03 pm, AE lover <aelove... at (no spam) gmail.com> wrote:

Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

---------------------------------
I think I've seen where you get color artifacts if you do this in RGB
space, especially at edges (where the color changes abruptly).  This
is reduced if you interpolate in a different color space such as HSI
(which takes into account interactions, like you say, because the HSI
bands are weighted sums or formulas of RGB.)http://www.easyrgb.com/index..php?X=MATH

Regards,
ImageAnalyst

You cannot properly interpolate on the H channel.  Suppose you have a
red ( H = 0 degrees ) object against a blue ( H = 240 ) background.
Bilinearly interpolating to the middle you get H = 120 so you will get
a lime green border around the object. Not to mention 0 and 359 are
both red so you can get every other color interpolating within a
completely red region.

I have seen odd instances where changing the RGB gamma to 2.2 (or is
it the reciprocal) produces better results, but in most cases it is
better leave gamma alone.

Thomas Richter already said everything important.- Hide quoted text -

- Show quoted text -
----------------------------------------------------------------------------

But why can't you interpolate in a more intelligent way? You go
around the clock in the direction that is closest, so the average of 0
and 359 would be 359.5 (still a red), and the average of 0 and 240
would be 300 (rather than 120) which is a purple which seems like it
could be a reasonable and acceptable interpolation of red and blue.
ImageAnalyst...
Posted: Sun May 25, 2008 4:17 am
Guest
On May 22, 12:03 pm, AE lover <aelove... at (no spam) gmail.com> wrote:
Quote:
Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

-----------------------------------------
AE Lover (Is that for "AutoExposure Lover"? That's the only AE
acronymI know of in imaging.)
You need to look into demosaicing algorithms. They do exactly what
you want.
http://www.google.com/search?hl=en&q=demosaicing+algorithms
Regards,
ImageAnalyst
aruzinsky...
Posted: Sun May 25, 2008 5:59 am
Guest
On May 24, 7:59 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:
Quote:
On May 24, 12:14 pm, aruzinsky <aruzin... at (no spam) general-cathexis.com> wrote:



On May 23, 7:40 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:

On May 22, 12:03 pm, AE lover <aelove... at (no spam) gmail.com> wrote:

Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

---------------------------------
I think I've seen where you get color artifacts if you do this in RGB
space, especially at edges (where the color changes abruptly).  This
is reduced if you interpolate in a different color space such as HSI
(which takes into account interactions, like you say, because the HSI
bands are weighted sums or formulas of RGB.)http://www.easyrgb.com/index.php?X=MATH

Regards,
ImageAnalyst

You cannot properly interpolate on the H channel.  Suppose you have a
red ( H = 0 degrees ) object against a blue ( H = 240 ) background.
Bilinearly interpolating to the middle you get H = 120 so you will get
a lime green border around the object. Not to mention 0 and 359 are
both red so you can get every other color interpolating within a
completely red region.

I have seen odd instances where changing the RGB gamma to 2.2 (or is
it the reciprocal) produces better results, but in most cases it is
better leave gamma alone.

Thomas Richter already said everything important.- Hide quoted text -

- Show quoted text -

---------------------------------------------------------------------------­-
But why can't you interpolate in a more intelligent way?  You go
around the clock in the direction that is closest, so the average of 0
and 359 would be 359.5 (still a red), and the average of 0 and 240
would be 300 (rather than 120) which is a purple which seems like it
could be a reasonable and acceptable interpolation of red and blue.- Hide quoted text -

- Show quoted text -

What do you propose to do with red, H=0, versus cyan, H=180? Either
midpoint yellow-green, H = 90 or purple, H = 270, is visually
undesireable.

RGB Bilinear 5X red vs. cyan: http://www.general-cathexis.com/images/rgbBilinear5X.png

HSI Bilinear 5X red vs. cyan: http://www.general-cathexis.com/images/hsiBilinear5X.png

HSI other way around Bilinear 5X: http://www.general-cathexis.com/images/hsi2Bilinear5X.png
Harris...
Posted: Sun May 25, 2008 6:16 am
Guest
AE lover <aelover11 at (no spam) gmail.com> wrote in news:2a03e221-19de-4e85-81d1-0b0e3ee4d7e3
at (no spam) k37g2000hsf.googlegroups.com:

Quote:
Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks


Since resizing is a spatial transformation, it should be invariant to intensity levels (mono or RGB).
Hence, it should not really matter if you do 3x (RGB) or 1x resizing (mono). On the other hand,
interpolation errors on reparate RGB channels may produce a new (combined) pixel value slightly
different of the original one, leading to a color-distorted image (probably in the form of small color shifts
at pixel-level scales).

My advice would be: (1) store the RGB ratios for each pixel, i.e., keep the original image, (2) convert
the image into intensity matrix using a standard (linear) formula, (3) resize the intensity matrix, (4)
convert the intensity matrix back to RGB using the values/ratios for each pixel form the original image.
The single-channel approach cuts down your processing time almost to a factor of one-third (plus
RGB conversions). Of course, you also need a mapping from the original to the new pixels (1 pixel ->
N pixels), so it is much simpler if you use integer multipliers in resizing (e.g. x2, x3, etc).


--
Harris
Marco Al...
Posted: Sun May 25, 2008 7:59 am
Guest
AE lover wrote:

Quote:
If so, why don't we take into account the interaction between three
channels?

What interaction did you have in mind?

R1 is a convolution over the spectrum of color 1, R2 is the same
convolution over the spectrum of color 2 ... if I make a weighted blend
of color spectrum 1 and 2 and apply the convolutions, hey what do you
know I get the same result as blending R1 and R2 with the same weights.

I see no interaction with the other colors. Of course this is assuming
linear RGB ... it's non trivial to get close to linear RGB, but black
level correction and gamma expansion will probably get you close enough.
Especially since you are using bilinear interpolation :)

Marco
ImageAnalyst...
Posted: Sun May 25, 2008 8:33 am
Guest
On May 25, 11:59 am, aruzinsky <aruzin... at (no spam) general-cathexis.com> wrote:
Quote:
On May 24, 7:59 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:





On May 24, 12:14 pm, aruzinsky <aruzin... at (no spam) general-cathexis.com> wrote:

On May 23, 7:40 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:

On May 22, 12:03 pm, AE lover <aelove... at (no spam) gmail.com> wrote:

Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

---------------------------------
I think I've seen where you get color artifacts if you do this in RGB
space, especially at edges (where the color changes abruptly).  This
is reduced if you interpolate in a different color space such as HSI
(which takes into account interactions, like you say, because the HSI
bands are weighted sums or formulas of RGB.)http://www.easyrgb.com/index.php?X=MATH

Regards,
ImageAnalyst

You cannot properly interpolate on the H channel.  Suppose you have a
red ( H = 0 degrees ) object against a blue ( H = 240 ) background..
Bilinearly interpolating to the middle you get H = 120 so you will get
a lime green border around the object. Not to mention 0 and 359 are
both red so you can get every other color interpolating within a
completely red region.

I have seen odd instances where changing the RGB gamma to 2.2 (or is
it the reciprocal) produces better results, but in most cases it is
better leave gamma alone.

Thomas Richter already said everything important.- Hide quoted text -

- Show quoted text -

---------------------------------------------------------------------------­­-
But why can't you interpolate in a more intelligent way?  You go
around the clock in the direction that is closest, so the average of 0
and 359 would be 359.5 (still a red), and the average of 0 and 240
would be 300 (rather than 120) which is a purple which seems like it
could be a reasonable and acceptable interpolation of red and blue.- Hide quoted text -

- Show quoted text -

What do you propose to do with red, H=0, versus cyan, H=180?  Either
midpoint yellow-green, H = 90 or purple, H = 270, is visually
undesireable.

RGB Bilinear 5X red vs. cyan:http://www.general-cathexis.com/images/rgbBilinear5X.png

HSI Bilinear 5X red vs. cyan:http://www.general-cathexis.com/images/hsiBilinear5X.png

HSI other way around Bilinear 5X:http://www.general-cathexis.com/images/hsi2Bilinear5X.png- Hide quoted text -

- Show quoted text -
----------------------------------------------------------------------------

I don't propose anything because there are cases where there are no
visually acceptable interpolated colors, as you proved. So there are
times when it doesn't "work" and there are times when it does.
Mathematically it can be done but it's up to the use to say what is
acceptable or unacceptable in their situation.
Regards,
ImageAnalyst
aruzinsky...
Posted: Sun May 25, 2008 8:56 am
Guest
On May 25, 10:16 am, Harris <xgeorg... at (no spam) pathfinder.gr> wrote:
Quote:
AE lover <aelove... at (no spam) gmail.com> wrote in news:2a03e221-19de-4e85-81d1-0b0e3ee4d7e3
at (no spam) k37g2000hsf.googlegroups.com:

Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

Since resizing is a spatial transformation, it should be invariant to intensity levels (mono or RGB).
Hence, it should not really matter if you do 3x (RGB) or 1x resizing (mono). On the other hand,
interpolation errors on reparate RGB channels may produce a new (combined) pixel value slightly
different of the original one, leading to a color-distorted image (probably in the form of small color shifts
at pixel-level scales).

My advice would be: (1) store the RGB ratios for each pixel, i.e., keep the original image, (2) convert
the image into intensity matrix using a standard (linear) formula, (3) resize the intensity matrix, (4)
convert the intensity matrix back to RGB using the values/ratios for each pixel form the original image.
The single-channel approach cuts down your processing time almost to a factor of one-third (plus
RGB conversions). Of course, you also need a mapping from the original to the new pixels (1 pixel -
N pixels), so it is much simpler if you use integer multipliers in resizing (e.g. x2, x3, etc).

--
Harris

Let me paraphrase that:

1. Y = a*R + b*G + c*B + d, (d is small positive number to prevent
division by zero)

2. ratioR = R/Y, ratioG = G/Y, ratioB = B/Y

3. Interpolate: Y' = bilinear(Y), ratioR' = box(ratioR), ratioG' box(ratioG), ratioB' = box(ratioB)

4. R' = Y'*ratioR', G' = Y'*ratioG', B' = Y'*ratioB'


Bilinear interpolation on RGB is faster than these conversions.

I will digress here and say it that it is bad practice to put one's
thoughts ahead of empiricism. This is an ethical issue because it is
a major cause of chaos in society.

I know from experience that you can do fancy interpolation on the Y
channel of YCbCr space and sloppy interpolation on th Cb and Cr
channels, but "fancy" here is nonlinear and relatively slow.
aruzinsky...
Posted: Sun May 25, 2008 12:48 pm
Guest
Correction:

AFter giving it more thought, I expect it is faster but not much.

The problem is with the result. Consider an edge with red hue on one
side and cyan hue on the other, both of equal Y. Your method will
produce a result that is the same as box interpolation of RGB.

When people look at linear enlargements, they associate the blur with
that of an unfocused eye lens because that is their life experience
with blur. A lens blurs different colors independently and that is
why linear enlargement should also do it independently. In the case
of a red-cyan edge, the eye expects the blurred edge to be grayish.
Of course, for nonlinear enlargement that preserves sharp edges, this
does not apply.


aruzinsky wrote:
Quote:
On May 25, 10:16�am, Harris <xgeorg... at (no spam) pathfinder.gr> wrote:
AE lover <aelove... at (no spam) gmail.com> wrote in news:2a03e221-19de-4e85-81d1-0b0e3ee4d7e3
at (no spam) k37g2000hsf.googlegroups.com:

Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

Since resizing is a spatial transformation, it should be invariant to intensity levels (mono or RGB).
Hence, it should not really matter if you do 3x (RGB) or 1x resizing (mono). On the other hand,
interpolation errors on reparate RGB channels may produce a new (combined) pixel value slightly
different of the original one, leading to a color-distorted image (probably in the form of small color shifts
at pixel-level scales).

My advice would be: (1) store the RGB ratios for each pixel, i.e., keep the original image, (2) convert
the image into intensity matrix using a standard (linear) formula, (3) resize the intensity matrix, (4)
convert the intensity matrix back to RGB using the values/ratios for each pixel form the original image.
The single-channel approach cuts down your processing time almost to a factor of one-third (plus
RGB conversions). Of course, you also need a mapping from the original to the new pixels (1 pixel -
N pixels), so it is much simpler if you use integer multipliers in resizing (e.g. x2, x3, etc).

--
Harris

Let me paraphrase that:

1. Y = a*R + b*G + c*B + d, (d is small positive number to prevent
division by zero)

2. ratioR = R/Y, ratioG = G/Y, ratioB = B/Y

3. Interpolate: Y' = bilinear(Y), ratioR' = box(ratioR), ratioG' > box(ratioG), ratioB' = box(ratioB)

4. R' = Y'*ratioR', G' = Y'*ratioG', B' = Y'*ratioB'


Bilinear interpolation on RGB is faster than these conversions.

I will digress here and say it that it is bad practice to put one's
thoughts ahead of empiricism. This is an ethical issue because it is
a major cause of chaos in society.

I know from experience that you can do fancy interpolation on the Y
channel of YCbCr space and sloppy interpolation on th Cb and Cr
channels, but "fancy" here is nonlinear and relatively slow.
aruzinsky...
Posted: Sun May 25, 2008 1:07 pm
Guest
On May 25, 12:33 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:
Quote:
On May 25, 11:59 am, aruzinsky <aruzin... at (no spam) general-cathexis.com> wrote:



On May 24, 7:59 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:

On May 24, 12:14 pm, aruzinsky <aruzin... at (no spam) general-cathexis.com> wrote:

On May 23, 7:40 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:

On May 22, 12:03 pm, AE lover <aelove... at (no spam) gmail.com> wrote:

Hi all,

I am considering the case of bilinear interpolation for a color image
(say RGB image), to apply a bilinear interpolation, will we apply the
formular of bilinear interpolation, which we use for a gray image, for
each channel R, G, and B, separately?
If so, why don't we take into account the interaction between three
channels?

Thanks

---------------------------------
I think I've seen where you get color artifacts if you do this in RGB
space, especially at edges (where the color changes abruptly).  This
is reduced if you interpolate in a different color space such as HSI
(which takes into account interactions, like you say, because the HSI
bands are weighted sums or formulas of RGB.)http://www.easyrgb.com/index.php?X=MATH

Regards,
ImageAnalyst

You cannot properly interpolate on the H channel.  Suppose you have a
red ( H = 0 degrees ) object against a blue ( H = 240 ) background.
Bilinearly interpolating to the middle you get H = 120 so you will get
a lime green border around the object. Not to mention 0 and 359 are
both red so you can get every other color interpolating within a
completely red region.

I have seen odd instances where changing the RGB gamma to 2.2 (or is
it the reciprocal) produces better results, but in most cases it is
better leave gamma alone.

Thomas Richter already said everything important.- Hide quoted text -

- Show quoted text -

---------------------------------------------------------------------------­­­-
But why can't you interpolate in a more intelligent way?  You go
around the clock in the direction that is closest, so the average of 0
and 359 would be 359.5 (still a red), and the average of 0 and 240
would be 300 (rather than 120) which is a purple which seems like it
could be a reasonable and acceptable interpolation of red and blue.- Hide quoted text -

- Show quoted text -

What do you propose to do with red, H=0, versus cyan, H=180?  Either
midpoint yellow-green, H = 90 or purple, H = 270, is visually
undesireable.

RGB Bilinear 5X red vs. cyan:http://www.general-cathexis.com/images/rgbBilinear5X.png

HSI Bilinear 5X red vs. cyan:http://www.general-cathexis.com/images/hsiBilinear5X.png

HSI other way around Bilinear 5X:http://www.general-cathexis.com/images/hsi2Bilinear5X.png-Hide quoted text -

- Show quoted text -

---------------------------------------------------------------------------­-
I don't propose anything because there are cases where there are no
visually acceptable interpolated colors, as you proved.  So there are
times when it doesn't "work" and there are times when it does.
Mathematically it can be done but it's up to the use to say what is
acceptable or unacceptable in their situation.
Regards,
ImageAnalyst- Hide quoted text -

- Show quoted text -

I proved no such thing. The RGB results are much more acceptable
because the typical human eye expects to see a grayish boundary
between red and cyan because that is what an unfocused lens does.
Blur is undesireable, but when it is unavoidable, it better resemble
natural blur.
 
Page 1 of 3    Goto page 1, 2, 3  Next   All times are GMT - 5 Hours
The time now is Fri Aug 29, 2008 1:52 pm