Re: interpolation for a color image?



On May 28, 6:58 pm, aruzinsky <aruzin...@xxxxxxxxxxxxxxxxxxxx> wrote:
On May 28, 1:39 am, illywhacker <illywac...@xxxxxxxxx> wrote:





On May 26, 6:35 pm, aruzinsky <aruzin...@xxxxxxxxxxxxxxxxxxxx> wrote:

I interspersed my comments with yours.

On May 26, 4:31 am, Harris <xgeorg...@xxxxxxxxxxxxx> wrote:

aruzinsky <aruzin...@xxxxxxxxxxxxxxxxxxxx> wrote innews:0bf42d72-1f92-44df-aba2-687532433ede@xxxxxxxxxxxxxxxxxxxxxxxxxxxx:

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.

I really don't understand what your opinions (or mine) on social chaos has to do with image
processing. If you mean to say that I said a stupid thing just to look smart, then just say it.

You didn't answer my question.  Regarding, "to look smart," it is bad
practice to speculate motives.  Is this your confession?

My answer is this: bilinear is not a good interpolation method but it is fast. Since it works in 2D, it
requires 12 multiplications and 4 divisions per (new) pixel estimate..
If you have any doubt, see:http://en.wikipedia.org/wiki/Bilinear_interpolation.

That doesn't apply to enlargement because the problem is separable and
performed as 2 1D interpolations.  Assume input is m x n and output is
M x N  First, I calculate 2 weights per each x and 2 weights per each
y coordinate in the output; this is an O(M + N) calculation which is
speed-wise negligible.  Then I form an m x N image which involves only
2 multiplications and 1 addition per greyscale pixel.  Then, using the
m x  N image as input I repeat forming an M x N image.  The operations
counts are

m*N*( 2 mult + 1 add) + M*N*(2 mult + 1 add)  =

(M + m)*N*(2 mult + 1 add)

Thus, you have slightly more that 2 multiplications and 1 addition per
greyscale pixel.  (Actually, although I do indeed do it this way, this
is the first time I have done an operations count.  Seems too fast.  I
previously thought it involved 4 multiplications.  Maybe, I made a
mistake.  But, it is not going to change my method of calculation)

Your "paraphrase" of what I initially proposed is too
slow, because you don't really need all these conversions, only an intensity estimate (RGB -> mono)
and the original image:

(1).  I(x,y) = a*R(x,y)+b*G(x,y)+c*B(x,y)
(2).  apply bilinear interpolation on I(x,y)
(3).  convert back to RGB

Step 2 is the same as above, e.g. 12 multiplications and 4 divisions for bilinear per (new) pixel value.
Step 3 can be implemented using the original channel value and the value range: if I'(x,y) is the
interpolated value, then new Red is: R'(x,y) = I'(x,y)/I(x,y) * R(x,y).

1. You will end up dividing by zero when I(x,y) = 0.  There is some
computation overhead to avoid this.

2. There is some computation overhead in finding nearest neighbor.

As you can see, you proposal with full RGB interpolation requires 3x (12.mul+4.div) = 36.mul + 12.div

WRONG. WRONG. WRONG. Slightly more than 6 multiplications and 3
additions.

per pixel, probably with floating-point arithmetic due to the use of ratios. My proposal requires 1x (3.mul
+ bilinear + 1.mul+1.div) = 16.mul+5.div per pixel, which can be implemented easily with integer
arithmetic in steps 1 and 3 (no explicit ratios used).

Please do the math before you criticise someone else's motives and knowledge here.

--
Harris- Hide quoted text -

- Show quoted text -

I didn't criticize your motives because I don't know them. Answer my
question, were you speaking from experience?  If not, you should at
least tell the OP that you are speculating.- Hide quoted text -

- Show quoted text -

Since no one has stooped to defining a criterion of optimality here,
there is no empiricism, from you or anyone else. Unless your opinion
on how good it looks is the deciding factor of course.

illywhacker;- Hide quoted text -

- Show quoted text -

Wrong.  Here the criterion of optimality is operation counts.  I have
implemented bilinear interpolation in the manner I described.  It
exists.  It is reality.  It is not hypothetical.  It is not a plan.
Therefore it is empirical.- Hide quoted text -

- Show quoted text -

So if the criterion of optimality is operation counts, I have the best
possible algorithm: do nothing!

illywhacker;
.



Relevant Pages

  • Re: interpolation for a color image?
    ... multiplications and 1 addition per greyscale pixel. ... Step 3 can be implemented using the original channel value and the value range: ... there is no empiricism, ... implemented bilinear interpolation in the manner I described. ...
    (sci.image.processing)
  • Re: interpolation for a color image?
    ... Step 3 can be implemented using the original channel value and the value range: ... there is no empiricism, ...  Here the criterion of optimality is operation counts. ... implemented bilinear interpolation in the manner I described. ...
    (sci.image.processing)
  • Re: interpolation for a color image?
    ... multiplications and 1 addition per greyscale pixel. ... Step 3 can be implemented using the original channel value and the value range: ... there is no empiricism, ... criterion is operation counts, then why not simply duplicate pixel ...
    (sci.image.processing)
  • Re: interpolation for a color image?
    ... multiplications and 1 addition per greyscale pixel. ... Step 3 can be implemented using the original channel value and the value range: ... there is no empiricism, ... criterion is operation counts, then why not simply duplicate pixel ...
    (sci.image.processing)
  • Re: interpolation for a color image?
    ... requires 12 multiplications and 4 divisions per pixel estimate. ... multiplications and 1 addition per greyscale pixel. ... Step 3 can be implemented using the original channel value and the value range: ... there is no empiricism, ...
    (sci.image.processing)