Posted by
Michael Schmid on
URL: http://imagej.273.s1.nabble.com/How-are-images-larger-than-the-display-window-rendered-tp5024669p5024673.html
Hi Kenneth,
you can easily try it yourself, by drawing a 1-pixel wide line at some
angle close to horizontal or vertical and zooming out.
At least my version of Java (Oracle Java 1.8) does 2x2 averaging of the
displayed colors, not the pixel values when zooming out.
When using a color LUT, this can also make some sense:
If I have, e.g. the 'Fire LUT' and the line appears purple at pixel
value 64, on a background that is while (pixel value 255), one may
expect that the zoomed-out line does not appear orange (corresponding to
pixel value ~160) but a lighter shade of purple.
Similarly, if the image shows noise (with about equal occurrence of all
valeus between 0 and 255), and a spectrum LUT is applied, one may expect
less saturated colors of all different hue values, not everything in
blue-turquioise shades corresponding to mid-values, which would be the
result of averaging pixel values.
Of course, with an image using indexed colors (such as graphics saved as
GIF), where the colors do not represent a gradual variations of some
numeric value, the only way to go is averaging colors, not index values.
Concerning the details of the (2x2) averaging:
Looking more closely, it seems that this is not really averaging but
just a result of interpolation: Java seems to calculate the coordinate
that the pixel center of the scaled image would have in the original
image. If it falls onto a pixel center, the pixel coordinate is used. If
if falls in between two pixels, linear interpolation of the colors is used.
With a zoom level of 50%, 25%, etc., the coordinates of the pixel
centers in the zoomed image are always at pixel boundaries of the
original image (when taking the pixels as small squares). This is what
causes the averaging.
If the zoom level is different, this can result in interpolation or not.
E.g., at zoom levels of 100/3 ~ 33.33333% and 100/5 = 20% zoom, the
zoomed pixel centers would coincide with centers of the original pixels.
Indeed, in this case I see no averaging but only sub-sampling.
Michael
________________________________________________________________
On 01.06.21 00:02, Kenneth Sloan wrote:
> Well..."strictly speaking" the display software should gamma correct the original (non-zoomed) version of the image, too. I don't think that is done, so I wouldn't worry about how averaging is done, either.
>
> Now...suppose I have applied a gamma-correcting LUT. Does the averaging process deal with the original data (in which case, the LUT will continue to do the right thing) or does it deal with the pixel values AFTER transformation by the LUT?
>
> Same question for the case when the LUT colorizes a scalar image - are the *colors* averaged, or the scalar pixel values?
>
> --
> Kenneth Sloan
>
[hidden email]
> Vision is the art of seeing what is invisible to others.
>
>
>
>
>
>> On May 31, 2021, at 09:17, Michael Schmid <
[hidden email]> wrote:
>>
>> (Strictly speaking, since the display is nonlinear, one should not use a mid gray level like 128 for the average of two pixels with 255 and two with 0 but take the Gamma value of the display into account. At least my Java version does not do this.)
>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html