Home » Eclipse Projects » Nebula » Transparent pixels in IntensityGraphFigure
|
Re: Transparent pixels in IntensityGraphFigure [message #1769095 is a reply to message #1769089] |
Wed, 26 July 2017 13:33 |
Jonah Graham Messages: 416 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
|
|
| | | |
Goto Forum:
Current Time: Sat Sep 07 21:11:35 GMT 2024
Powered by FUDForum. Page generated in 0.03935 seconds
|