Re: Operating at the pixel level with a PNG or x11 [SEC=UNCLASSIFIED]

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Mon Feb 13 2012 - 15:10:18 MST

Griff,

I think you can get close to what you want by plotting a "contour" map
in raster fill mode as suggested off line by Evelyn G. Instead of
the nested loop in your original e-mail, you can plot reg->land
directly because it is just a 2-D grid of numbers. Just specify an
NCL color map and contour levels so that land plots in the desired
color, and water is white. Details of how to do this can be found in
other NCL examples. Get this part working before wrestling with the
trickier PNG and sizing issues.

There are NCL controls to turn off all of the visible edge labeling
elements -- titles, tick marks, etc. Look under examples and
resources.

For PNG output, set png@wkHeight and png@wkWidth to approximately the
size of your land data grid, as you had in your original e-mail. I
think you will need to have a little extra to accommodate NCL's white
borders on all four sides. For simplicity, maintain wkHeight =
wkWidth. Test and adjust wkHeight/wkWidth incrementally until you get
exact 1:1 correspondence between data grid cells and visible image
pixels. (This is experimental; I have never tried making small images
like this.)

If needed, post process with convert (ImageMajick) to remove white
borders and get a rectangular shaped result. "convert -trim +repage"
crops all white borders down to the outermost non-white pixels, so you
don't need to specify cropping measurements. There are other convert
tricks that you might prefer.

The most significant problem is that the PNG driver in the current NCL
version has an anti-aliasing filter that can not be turned off (as far
as I was last told). This means that the color of individual pixels
is blended somewhat with adjacent pixels, and you can't get complete
control over a single pixel. I suggest that you experiment with this
approach, and see whether the resulting image is good enough.

--Dave

On Sun, Feb 12, 2012 at 2:22 PM, Griffith Young <G.Young@bom.gov.au> wrote:
>>> The term "pixel" has several different uses.
>>> In computer graphics it often refers to individual picture cells or color elements in a raster graphic format such as PNG or JPEG.
>
> The first term is the one I am thinking of.
>
>>> Do you really want to set individual PNG picture cells
>
> Yes
>
>>> Your reference to "reg->land(lat, lon)" appears to be a data grid reference.
>>> This implies that you are working at the data cell level, not the image cell level.
>
> reg->land is an array of 178 by 139 mask bits.
>
> I would like a PNG that is coloured for the mask bits and background for the unmasked bits.
>
> I had hoped this would be easier than plotting a contour map, trimming the default text, then resizing to 178, 139.  I can do this, but it appears to be an ugly implementation.
>
> It is possible that I am thinking about this process at too low a level.
>
> Thanks,
>    Griff Young.
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Feb 13 15:10:31 2012

This archive was generated by hypermail 2.1.8 : Fri Feb 17 2012 - 08:50:10 MST