Commit 3ddc661d authored by Andrey Filippov's avatar Andrey Filippov

Getting processed LWIR images

parent adf9d12f
...@@ -26,11 +26,11 @@ public class ThermalColor { ...@@ -26,11 +26,11 @@ public class ThermalColor {
public double [] getRGB(double v) { // Get R,G,B (0..255) triplet for input value in the range 0..1 public double [] getRGB(double v) { // Get R,G,B (0..255) triplet for input value in the range 0..1
double k = out_range/PALETTE_RANGE; double k = out_range/PALETTE_RANGE;
double value = (v-min)/(max-min); double value = (v-min)/(max-min) * (this.palette.length - 1);
int ivalue = (int) (value/(this.palette.length - 1)); int ivalue = (int) (value);
if (ivalue < 0) return this.palette[0]; if (ivalue < 0) return this.palette[0];
if (ivalue >= (this.palette.length -1)) return this.palette[this.palette.length -1]; if (ivalue >= (this.palette.length -1)) return this.palette[this.palette.length -1];
double a = (value-ivalue)*(this.palette.length - 1); // 0..1 double a = (value-ivalue); // 0..1
double [] rslt = { double [] rslt = {
k*((1 - a) * this.palette[ivalue][0] + a * this.palette[ivalue+1][0]), k*((1 - a) * this.palette[ivalue][0] + a * this.palette[ivalue+1][0]),
k*((1 - a) * this.palette[ivalue][1] + a * this.palette[ivalue+1][1]), k*((1 - a) * this.palette[ivalue][1] + a * this.palette[ivalue+1][1]),
...@@ -97,7 +97,8 @@ public class ThermalColor { ...@@ -97,7 +97,8 @@ public class ThermalColor {
0xfff285, 0xfff28a, 0xfff38e, 0xfff492, 0xfff496, 0xfff49a, 0xfff59e, 0xfff5a2, 0xfff285, 0xfff28a, 0xfff38e, 0xfff492, 0xfff496, 0xfff49a, 0xfff59e, 0xfff5a2,
0xfff5a6, 0xfff6aa, 0xfff6af, 0xfff7b3, 0xfff7b6, 0xfff8ba, 0xfff8bd, 0xfff8c1, 0xfff5a6, 0xfff6aa, 0xfff6af, 0xfff7b3, 0xfff7b6, 0xfff8ba, 0xfff8bd, 0xfff8c1,
0xfff8c4, 0xfff9c7, 0xfff9ca, 0xfff9cd, 0xfffad1, 0xfffad4, 0xfffbd8, 0xfffcdb, 0xfff8c4, 0xfff9c7, 0xfff9ca, 0xfff9cd, 0xfffad1, 0xfffad4, 0xfffbd8, 0xfffcdb,
0xfffcdf, 0xfffde2, 0xfffde5, 0xfffde8, 0xfffeeb, 0xfffeee, 0xfffef1, 0xfffef4, 0xfffff}; 0xfffcdf, 0xfffde2, 0xfffde5, 0xfffde8, 0xfffeeb, 0xfffeee, 0xfffef1, 0xfffef4,
0xffffff};
int [][] palettes = {white_hot_palette, black_hot_palette, iron_palette}; int [][] palettes = {white_hot_palette, black_hot_palette, iron_palette};
if (indx <0) indx = 0; if (indx <0) indx = 0;
else if (indx >= palettes.length) indx = palettes.length - 1; else if (indx >= palettes.length) indx = palettes.length - 1;
......
...@@ -1838,6 +1838,57 @@ public class EyesisCorrections { ...@@ -1838,6 +1838,57 @@ public class EyesisCorrections {
return imp; return imp;
} }
public static ImagePlus convertRGBAFloatToRGBA32(
ImageStack stackFloat, //r,g,b,a
String title,
double r_min,
double r_max,
double g_min,
double g_max,
double b_min,
double b_max,
double alpha_min,
double alpha_max){
double [] mins= {r_min,g_min,b_min,alpha_min};
double [] maxs= {r_max,g_max,b_max,alpha_max};
int i;
int length=stackFloat.getWidth()*stackFloat.getHeight();
int numSlices = stackFloat.getSize();
if (numSlices > 4) numSlices = 4;
float [][] fpixels=new float[numSlices][];
int [] sliceSeq = new int [numSlices];
for (int j = 0; j < numSlices; j++) sliceSeq[j] = (j + ((numSlices > 3)? 3:0)) % 4;
int [] pixels=new int[length];
int c,d;
double [] scale=new double[numSlices];
for (c = 0; c < numSlices; c++) {
scale[c]=256.0/(maxs[c]-mins[c]);
}
for (i = 0; i < numSlices; i++) {
fpixels[i]= (float[])stackFloat.getPixels(i+1);
}
for (i = 0; i < length; i++) {
pixels[i]=0;
for (int j=0; j < numSlices; j++) {
c = sliceSeq[j];
d=(int)((fpixels[c][i]-mins[c])*scale[c]);
if (d > 255) d=255;
else if (d < 0) d=0;
pixels[i]= d | (pixels[i] << 8);
}
}
ColorProcessor cp=new ColorProcessor(stackFloat.getWidth(),stackFloat.getHeight());
cp.setPixels(pixels);
ImagePlus imp=new ImagePlus(title,cp);
return imp;
}
public ImageStack convertRGB48toRGBA24Stack( public ImageStack convertRGB48toRGBA24Stack(
ImageStack stack16, ImageStack stack16,
double [] dalpha, // alpha pixel array 0..1.0 or null double [] dalpha, // alpha pixel array 0..1.0 or null
......
...@@ -4505,6 +4505,10 @@ public class QuadCLT { ...@@ -4505,6 +4505,10 @@ public class QuadCLT {
} }
} }
if (isLwir()) { if (isLwir()) {
String [] rgb_titles = {"red","green","blue"};
String [] rgba_titles = {"red","green","blue","alpha"};
String [] titles = (alpha == null) ? rgb_titles : rgba_titles;
int num_slices = (alpha == null) ? 3 : 4;
double offset = getLwirOffset(); double offset = getLwirOffset();
double mn = colorProcParameters.lwir_low - offset; double mn = colorProcParameters.lwir_low - offset;
double mx = colorProcParameters.lwir_high - offset; double mx = colorProcParameters.lwir_high - offset;
...@@ -4513,13 +4517,38 @@ public class QuadCLT { ...@@ -4513,13 +4517,38 @@ public class QuadCLT {
mn, mn,
mx, mx,
255.0); 255.0);
rbg_in = new double [3][iclt_data[green_index].length]; double [][] rgba = new double [num_slices][];
for (int i = 0; i < rbg_in[0].length; i++) { for (int i = 0; i < 3; i++) rgba[i] = new double [iclt_data[green_index].length];
for (int i = 0; i < rbg_in[green_index].length; i++) {
if (i == 700) {
System.out.println("linearStackToColor(): i="+i);
}
double [] rgb = tc.getRGB(iclt_data[green_index][i]); double [] rgb = tc.getRGB(iclt_data[green_index][i]);
rbg_in[0][i] = rgb[0]; // red rgba[0][i] = rgb[0]; // red
rbg_in[1][i] = rgb[2]; // blue rgba[1][i] = rgb[1]; // green
rbg_in[2][i] = rgb[1]; // green rgba[2][i] = rgb[2]; // blue
} }
if (alpha != null) {
rgba[3] = alpha; // 0..1
}
ImageStack stack = sdfa_instance.makeStack(
rgba, // iclt_data,
width, // (tilesX + 0) * clt_parameters.transform_size,
height, // (tilesY + 0) * clt_parameters.transform_size,
titles, // or use null to get chn-nn slice names
true); // replace NaN with 0.0
ImagePlus imp_rgba = EyesisCorrections.convertRGBAFloatToRGBA32(
stack, // ImageStack stackFloat, //r,g,b,a
name+"ARGB"+suffix, // String title,
0.0, // double r_min,
255.0, // double r_max,
0.0, // double g_min,
255.0, // double g_max,
0.0, // double b_min,
255.0, // double b_max,
0.0, // double alpha_min,
1.0); // double alpha_max)
return imp_rgba;
} }
ImageStack stack = sdfa_instance.makeStack( ImageStack stack = sdfa_instance.makeStack(
...@@ -4659,6 +4688,7 @@ public class QuadCLT { ...@@ -4659,6 +4688,7 @@ public class QuadCLT {
titleFull=name+"-YPrPb"+suffix; titleFull=name+"-YPrPb"+suffix;
if (debugLevel > 1) System.out.println("Using full stack, including YPbPr"); if (debugLevel > 1) System.out.println("Using full stack, including YPbPr");
} }
if (alpha_pixels != null){ if (alpha_pixels != null){
stack.addSlice("alpha",alpha_pixels); stack.addSlice("alpha",alpha_pixels);
} }
...@@ -8178,7 +8208,7 @@ public class QuadCLT { ...@@ -8178,7 +8208,7 @@ public class QuadCLT {
texture_overlap[alpha_index][i] = d; texture_overlap[alpha_index][i] = d;
} }
} }
// for now - use just RGB. Later add oprion for RGBA // for now - use just RGB. Later add option for RGBA
double [][] texture_rgb = {texture_overlap[0],texture_overlap[1],texture_overlap[2]}; double [][] texture_rgb = {texture_overlap[0],texture_overlap[1],texture_overlap[2]};
double [][] texture_rgba = {texture_overlap[0],texture_overlap[1],texture_overlap[2],texture_overlap[3]}; double [][] texture_rgba = {texture_overlap[0],texture_overlap[1],texture_overlap[2],texture_overlap[3]};
double [][] texture_rgbx = ((clt_parameters.alpha1 > 0)? texture_rgba: texture_rgb); double [][] texture_rgbx = ((clt_parameters.alpha1 > 0)? texture_rgba: texture_rgb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment