Login  Register

Re: Trouble with plugin / image backgrounds

Posted by Wayne Rasband on Jul 19, 2005; 3:49pm
URL: http://imagej.273.s1.nabble.com/Trouble-with-plugin-image-backgrounds-tp3705226p3705227.html

The setBackgroundValue() method was added in ImageJ 1.34p.

Here is a macro that rotates an image by a specified number of degrees,
filling with the image average.

    requires("1.34p");
    angle = 25;
    getRawStatistics(area, mean);
    setBackgroundColor(mean, mean, mean);
    run("Arbitrarily...", "interpolate fill angle="+angle);

-wayne

On Jul 19, 2005, at 9:58 AM, Benjamin Blonder wrote:

> Hello,
>   I'm trying to write a plugin filter for 8-bit grayscale images. I'd
> like to  have a method that takes an ImageProcessor, angle,
> and grayscale value, and then rotates the image by the requested
> number of degrees, filling in the  background with the value.
>
>  Right now I have
>
>  public void rotate(ImageProcessor ip, int degrees)
> {
>   double average = // calculated here
>   ip.setBackgroundValue(average);
>  ip.rotate(degrees);
> }
>
> This doesn't compile, however. I get this error:
>
>  C:\Program Files\ImageJ\plugins\SPR_Position.java:51: Method
> setBackgroundValue(double) not found in class
> ij.process.ImageProcessor.
>
> ip.setBackgroundValue(average);
>
>                      ^
>
> 1 error
>
> All the ImageJ documentation has this method listed as existing, and
> I'm
> positive that ip is a ByteProcessor, so it ought to do what it claims.
> Any
> suggestions on how to fix this? I'm using ImageJ 1.33u on Windows XP.
>
> Thanks,
> Ben