resize image

C

cmk128

Hi
I really can't find a c++/java example about bicubic algorithm. I
want to resize an image, would you like to tell me where i can find an
example on web?
thanks
from Peter ([email protected])
 
O

opalpa opalpa

I don't know what bicubic is. If you want to resize image here you go:


public static BufferedImage scale(BufferedImage img, double scale) {
if (scale<0.0)
scale = 0.0;
AffineTransformOp op = new AffineTransformOp
(AffineTransform.getScaleInstance(scale, scale), null);
return op.filter(img, null);
}

Opalinski
(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
C

cmk128

opalpa (e-mail address removed) opalinski 寫é“:
I don't know what bicubic is. If you want to resize image here you go:


public static BufferedImage scale(BufferedImage img, double scale) {
if (scale<0.0)
scale = 0.0;
AffineTransformOp op = new AffineTransformOp
(AffineTransform.getScaleInstance(scale, scale), null);
return op.filter(img, null);
}

Opalinski
(e-mail address removed)
http://www.geocities.com/opalpaweb/


thanks
but i cann't use third-party API, i need to do it my own.
thanks
from Peter
 
P

persenaama

Hi
I really can't find a c++/java example about bicubic algorithm. I
want to resize an image, would you like to tell me where i can find an
example on web?

Tried Google? The first hit is what you want, or is there a specific
problem you are facing how to write the equation in C++/Java?
 
T

Thomas Weidenfeller

Hi
I really can't find a c++/java example about bicubic algorithm. I
want to resize an image, would you like to tell me where i can find an
example on web?
thanks
from Peter ([email protected])

Hey Peter,

while you are her with your "Peter ([email protected])" identity,
please tell us why you spam this and other Java groups as
(e-mail address removed), Dan, Advanced Telesoft, eh? And no, I don't
want to know what you are doing with your
"(e-mail address removed)" identity.

/Thomas
 
C

cmk128

persenaama 寫é“:
Tried Google? The first hit is what you want, or is there a specific
problem you are facing how to write the equation in C++/Java?

Hi
I don't understand the fill-in sequence.
If i have a 2x2 pixels image:

XX
XX

Then i resize it to enlarge 100%, so i get

X?X?
?????
X?X?
?????

What is the sequence to fill the the ? (the unknown pixel)?
thanks
from Peter
 
C

cmk128

Thomas Weidenfeller 寫é“:
Hey Peter,

while you are her with your "Peter ([email protected])" identity,
please tell us why you spam this and other Java groups as
(e-mail address removed), Dan, Advanced Telesoft, eh? And no, I don't
want to know what you are doing with your
"(e-mail address removed)" identity.

/Thomas

Hi Thomas
I think is a mistake. i use groups.google.com rather than any
newgroup client.
thanks
from Peter
 
J

[Jongware]

(e-mail address removed)> wrote in message
persenaama ??:
Hi
I don't understand the fill-in sequence.
If i have a 2x2 pixels image:

Then i resize it to enlarge 100%, so i get

What is the sequence to fill the the ? (the unknown pixel)?

The correct term is "bicubic interpolation".
You can't add borders using this technique! You will have to choose what you
want: a border of a solid color, a wrap-around effect, or (usually) only
stretch inbetween pixels.
To stretch a value range (x1,x2) horizontally to (xn1,xn2), use this for
every value inbetween: new value = x1+(x2-x1)/(xn2-xn1) and calculate this
for each separate RGB component.
In ASCII art, your 4 top pixels again:

pixel number:
0 1 2 3
X [2/3X+1/3Y] [1/3X+2/3Y] Y

You can see pixel value #1 will be X+1*((Y-X)/3) = X - 1/3X + 1/3Y = 2/3X +
1/3Y
The same can be used for vertical scaling. You can do the horizontal and
vertical scaling in two separate passes, but the formula can be easily
adjusted to calculate *any* position inbetween.
There are lots and lots of optimizations that can be done, however, this
should get you started.

[Jongware]
 
C

Chris Uppal

[quoted in full deliberately]

Thomas Weidenfeller ??:


Hi Thomas
I think is a mistake. i use groups.google.com rather than any
newgroup client.
thanks
from Peter

There's a post from (e-mail address removed) today in comp.programmer. It's
written in the same style as you use, and it was posted from the same IP
address as your post above. Over the course of September
(e-mail address removed) sent around 60 spamming posts to various technical
newsgroups (all in Chinese as far as I can tell). Most of them came from the
same IP address as you were using for your posts at around the same time.

If you are genuinely not the same person as (e-mail address removed), then it
is almost certain that you and he (or she) work at the same organisation (quite
possibly even in the same room), since the most likely reason for you both to
be using the same IP address is that you are both behind the same NAT router.
Such routers are not used in large organisations. You should find that person,
and get him (or her) to stop giving you a bad name by abusing newsgroups.

Actually, a more plausible reason, to my mind, is that you /are/ in fact
(e-mail address removed), but that's only on the balance of the evidence. I
wouldn't claim there was complete proof of it.

-- chris
 
C

cmk128

[Jongware] 寫é“:
(e-mail address removed)> wrote in message
persenaama ??:
Hi
I don't understand the fill-in sequence.
If i have a 2x2 pixels image:

Then i resize it to enlarge 100%, so i get

What is the sequence to fill the the ? (the unknown pixel)?

The correct term is "bicubic interpolation".
You can't add borders using this technique! You will have to choose what you
want: a border of a solid color, a wrap-around effect, or (usually) only
stretch inbetween pixels.
To stretch a value range (x1,x2) horizontally to (xn1,xn2), use this for
every value inbetween: new value = x1+(x2-x1)/(xn2-xn1) and calculate this
for each separate RGB component.
In ASCII art, your 4 top pixels again:

pixel number:
0 1 2 3
X [2/3X+1/3Y] [1/3X+2/3Y] Y

You can see pixel value #1 will be X+1*((Y-X)/3) = X - 1/3X + 1/3Y = 2/3X +
1/3Y
The same can be used for vertical scaling. You can do the horizontal and
vertical scaling in two separate passes, but the formula can be easily
adjusted to calculate *any* position inbetween.
There are lots and lots of optimizations that can be done, however, this
should get you started.

[Jongware]

Thanks
But it is not bicubic interpolation i think, because bicubic
interpolation takes 16 points to calculate the average RGB.
thank you
 
J

[jongware]

[Jongware] ??:
(e-mail address removed)> wrote in message
persenaama ??:
Hi
I don't understand the fill-in sequence.
If i have a 2x2 pixels image:

Then i resize it to enlarge 100%, so i get

What is the sequence to fill the the ? (the unknown pixel)?

The correct term is "bicubic interpolation".
You can't add borders using this technique! You will have to choose what you
want: a border of a solid color, a wrap-around effect, or (usually) only
stretch inbetween pixels.
To stretch a value range (x1,x2) horizontally to (xn1,xn2), use this for
every value inbetween: new value = x1+(x2-x1)/(xn2-xn1) and calculate this
for each separate RGB component.
In ASCII art, your 4 top pixels again:

pixel number:
0 1 2 3
X [2/3X+1/3Y] [1/3X+2/3Y] Y

You can see pixel value #1 will be X+1*((Y-X)/3) = X - 1/3X + 1/3Y = 2/3X +
1/3Y
The same can be used for vertical scaling. You can do the horizontal and
vertical scaling in two separate passes, but the formula can be easily
adjusted to calculate *any* position inbetween.
There are lots and lots of optimizations that can be done, however, this
should get you started.

[Jongware]
Thanks
But it is not bicubic interpolation i think, because bicubic
interpolation takes 16 points to calculate the average RGB.

You're right.. this is bilinear interpolation :) <scratches head> How about
this:
<q>
weight = (( A + 2.0 )*x - ( A + 3.0 ))*x*x +1.0; 0<x<1
weight = (( A * x - 5.0 * A ) * x + 8.0 * A ) * x - 4.0 * A; 1<x<2
It uses 4 pixels in one, and 16 pixels in 2 dimensions. The parameter 'A'
determines the behavious of this function. It is set to -0.75, which makes
it very similar to Photoshop's bicubic interpolator.
</q>
copied from
http://www.path.unimelb.edu.au/~dersch/interpolator/interpolator.html ,
where you can find some more examples.

[Jongware]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top