Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Transparent pixels in IntensityGraphFigure
Transparent pixels in IntensityGraphFigure [message #1769089] Wed, 26 July 2017 12:30 Go to next message
Ian Mayo is currently offline Ian MayoFriend
Messages: 20
Registered: July 2009
Junior Member
I'm using the IntensityGraphFigure to produce a heatmap.

But, I have some missing values in the data array, which I have represented as Double.NAN

I'd like these pixels to be made transparent.

But, they are set to the minimum value in the data range.

Is there an alternate way of omitting some values from a heatmap?

The attached image shows a zone of pixels where the double value is set to Double.NAN
  • Attachment: DeadZone.PNG
    (Size: 14.80KB, Downloaded 55 times)
Re: Transparent pixels in IntensityGraphFigure [message #1769095 is a reply to message #1769089] Wed, 26 July 2017 13:33 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 401
Registered: June 2014
Senior Member
Hi Ian,

I don't know if there is another way, but one way you could do it is with a custom ColorMap. For example, the following with set NaN values to Alpha of 0 (transparent).


intensityGraph.setColorMap(new ColorMap(PredefinedColorMap.JET, true,true) {
	@Override
	public ImageData drawImage(IPrimaryArrayWrapper dataArray, int dataWidth, int dataHeight, double max,
			double min, ImageData imageData, boolean shrink) {
		imageData = super.drawImage(dataArray, dataWidth, dataHeight, max, min, imageData, shrink);
		if(shrink){
			int height = imageData.height;
			int width = imageData.width;
			    // EDIT: added +1 to account for an early rounding problem
			    int x_ratio = (int)((dataWidth<<16)/width) +1;
			    int y_ratio = (int)((dataHeight<<16)/height) +1;
			    //int x_ratio = (int)((w1<<16)/w2) ;
			    //int y_ratio = (int)((h1<<16)/h2) ;
			    int x2, y2 ;
			    for (int i=0;i<height;i++) {
			        for (int j=0;j<width;j++) {
			            x2 = ((j*x_ratio)>>16) ;
			            y2 = ((i*y_ratio)>>16) ;
			            double d = dataArray.get(y2 * dataWidth + x2);
			            if (Double.isNaN(d)) {
				            imageData.setAlpha(j,i,0);
			            } else {
				            imageData.setAlpha(j,i,255);
			            }
			        }
			    }


		}else{
			for (int y = 0; y < dataHeight; y++) {
				for (int x = 0; x < dataWidth; x++) {
					// the index of the value in the color table array
					double d = dataArray.get(y * dataWidth + x);
		            if (Double.isNaN(d)) {
			            imageData.setAlpha(x,y,0);
		            } else {
			            imageData.setAlpha(x,y,255);
		            }
				}
			}
		}
		return imageData;
	}
});



Alternatively, you can set the color for index 0 to a different color. See how pixelLookupTable is set-up in ColorMap.

HTH,
Jonah
Re: Transparent pixels in IntensityGraphFigure [message #1769096 is a reply to message #1769095] Wed, 26 July 2017 13:53 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 401
Registered: June 2014
Senior Member
PS It seems that some improvements to the API of ColorMap may be an option here. Patches welcome :-)
Re: Transparent pixels in IntensityGraphFigure [message #1769100 is a reply to message #1769096] Wed, 26 July 2017 14:21 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 401
Registered: June 2014
Senior Member
(accidentally submitted empty message, please disregard)

[Updated on: Wed, 26 July 2017 14:22]

Report message to a moderator

Re: Transparent pixels in IntensityGraphFigure [message #1769987 is a reply to message #1769100] Mon, 07 August 2017 09:55 Go to previous message
Ian Mayo is currently offline Ian MayoFriend
Messages: 20
Registered: July 2009
Junior Member
Hi there Jonah - that's a neat solution, thanks.

Image of fixed version attached.

Oh, and thanks for the prompt reply. I'd been checking the Nebula mailing list, not this group. Duh...

Cheers,
Ian

[Updated on: Mon, 07 August 2017 10:03]

Report message to a moderator

Previous Topic:Transparent Canvas inside a composite parent
Next Topic:How to increase height of GridColumnGroup Header in nebula Grid
Goto Forum:
  


Current Time: Sat Nov 17 17:34:51 GMT 2018

Powered by FUDForum. Page generated in 0.02034 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top