Skip to main content

Rotatedescriptor vs Rotate Operation black background

2 replies [Last post]
mslozano
Offline
Joined: 2009-11-16

the rotate operation add a black background when you execute de operation example:
ParameterBlock pb = new ParameterBlock();
pb.addSource(image);
pb.add(centerX);
pb.add(centerY);
pb.add(angle);
pb.add(new InterpolationBilinear());
// Creates a new, rotated image and uses it on the DisplayJAI component
PlanarImage rotatedImage = JAI.create("rotate", pb);

I read the JAI documentation and I found that RotateDescriptor class has the "create" method :
RenderedOp create(RenderedImage source0, Float xOrigin, Float yOrigin, Float angle, Interpolation interpolation, double[] backgroundValues, RenderingHints hints)

the parameter backgroundValues is used to define the background color

my cuestions are
what is the relation between Rotate descriptor and the classic use of rotate operation?
can I access the background property from parameterblock?
thanks in advance

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mslozano
Offline
Joined: 2009-11-16

thanks rafael santos for your response now my code is:
_rotPB = new ParameterBlockJAI("rotate");
_rotPB.setSource(this.image, 0);
_rotPB.setParameter("angle", 0.0f);
double background[] = {255.0,255.0,255.0};//white
_rotPB.setParameter("backgroundValues", background);
_rotImage = JAI.create("rotate", _rotPB, null);

Rafael Santos

Hello,
> I read the JAI documentation and I found that RotateDescriptor class has the "create" method :
> RenderedOp create(RenderedImage source0, Float xOrigin, Float yOrigin, Float angle, Interpolation interpolation, double[] backgroundValues, RenderingHints hints)
>
> the parameter backgroundValues is used to define the background color
>
> my cuestions are
> what is the relation between Rotate descriptor and the classic use of rotate operation?
>
The rotate operation is a convenient form to call the operator in an
image chain. Below there are calls to the operator that do the same.
> can I access the background property from parameterblock?
>
If by "access" you mean "change", you can do it with either:

ParameterBlock pb = new ParameterBlock();
pb.addSource(image);
pb.add(centerX);
pb.add(centerY);
pb.add(angle);
pb.add(new InterpolationBilinear());
pb.add(new double[]{0,255,255});
PlanarImage rotatedImage = JAI.create("rotate", pb);

or

PlanarImage rotatedImage =
RotateDescriptor.create(image,centerX,centerY,angle,new
InterpolationBilinear(),new double[]{0,255,255},null);

Curiously the color seems to be in BGR -- 0,255,255 is interpreted as
yellow by these calls. I've also noticed that the very edges of the
rotated image (1 or 2 pixels wide) appears cyan (RGB 0,255,255). When I
change the color to 0,0,255 the background is red but these edge pixels
become red. Probably a small bug in the operator.

Rafael

[att1.html]