Showing results for 
Search instead for 
Do you mean 

Histogram stretch in batch

by Technical Evangelist on ‎02-15-2016 06:24 AM - edited on ‎03-21-2016 02:39 PM by Anonymous (1,096 Views)

Symptoms

Here is the problem, as described by the client:
"I have a bunch of TIF tiles that I want to apply the same contrast stretch to. I
would like to apply the percentage LUT with .1% from left and 17% from right.

Doing this one by one is possible, but I don't know how to batch the process.

Diagnosis

So far what I have done is open an image in the viewer, go to
Raster>Contrast>General Contrast...>Percentage LUT(.1% from left and 17% from
right)>Apply>Close>File>Save>All Layers, then
Interpreter>Radiometric Enhancement...>LUT Stretch... which works fine for one TIF
at a time.

Can establishing the settings of the contrast stretch (Percentage LUT(.1% from left
and 17% from right)) be batched?

When I try to batch a bunch of TIFs via Interpreter>Radiometric Enhancement...>LUT
Stretch..., it process with the normal status/progress dialogue/window, but it never
outputs any TIFs."

 

"Interpreter > Radiometric Enhancement... >LUT Stretch..." and the "Percentage LUT
from viewer" are totally different process.

"Interpreter > Radiometric Enhancement...> LUT Stretch..." will use the lookup table
(from the input image) to create a new image, the digital number from the ouput
image will based on the lookup table. So make sure you have the lookup table from
the input image, if you don't, you will get the "Column contrast does not exist"
error.
"Percentage LUT from viewer" will only change the lookup table, the actuall digital
value will not change.

I think what you want is to batch "Percentage LUT from viewer".
Unfortunately there is no tool currently available for this, I am writing you a
spatial model for this. Hopefully I will be able to finish that model today or
tomorrow. I will let you know the follow up.

 

Thank you for investigating this issue. I think we are talking about two diiferent
procedures, i.e.:
1) applying an existing LUT in order to create a new image

(Interpreter/Radiometric Enhancement/LUT Stretch) and
2)applying a histogram stretch in the Viewer
(Standard Deviation, Percentage LUT etc.).
The testing that I mentioned about on January 19 involved the LUT Stretch for
Gaussian on .../examples/wasia1_mss.img and ...wasia2_mss.img (procedure 1 above).
While individual application of LUT Stretch works, the batch doesn't output
anything, just as for the client. Maybe I am doing something wrong, please check.

Regarding the second procedure above, are you saying that Percentage LUT histogram
stretch in the Viewer is stored in the LUT differently than, let's say, Standard
Deviation or Gaussian, and it won't output a modified radiometry if LUT Stretch
would be applied?

Please send us the model, as soon as completed, so that we can test it as well.

 

OK, let me repeat your questions:

1) apllying an existing LUT in order to create a new image
(Interpreter/Radiometric Enhancement/LUT Stretch) and
Yes, I can duplicate your problem. IMAGINE batch doesn't work, while Individual job
works.
I already submitted a bug fix on this problem
IMG-4700: The batch mode for "Interpreter-->Radiometric Enhancement-->LUT Stretch"
doesn't work

2)applying a histogram stretch in the Viewer
(Standard Deviation, Percentage LUT etc.).
I am working on a spatial model on this task, so user can do it in batch mode. I
will let you know the follow up.

 

 

Solution

(1) In order to see how the procedure works, I take one file,
.../examples/wasia3_tm.img. I open it in the Viewer, open the Attributes. The only
column I should see is Histogram. If more columns are present, e.g. Contrast and
Breakpoints, I have to run model1. If no other columns except Histogram exist,
model1 is not required.
Yes.
(2) In order to create a contrast table (an independent .tbl file), I have to open
the image in a Viewer, apply the required Percentage LUT (the client prefers: 0.1
Left and 17 Right), close the image and, when prompted, save the edits. Open the
image again, open the attributes and save the Contrast table to a .tbl file: does
the .tbl root need to match the name of the file?
NO. The name for .tbl file can be any thing.

What's next, i.e. what is the input of model2?
So far, model_2.gmd contains the hard-coded file name. If you open the graphic

model, and double click on the "n1_Read", you need to relink it to read
"output.tbl". (n1_Read, n2_Read, n3_Read are the same object)
You also need to relink the n4_Output, n5_Output, n6_Output to the different layer
for an existing raster image.
The next step is to change the hard coded model .gmd to a Spatial model (.mdl), so
you can supply variables (input & output) to the model and let it run in batch mode.

 

Thank you for your patience and detailed explanation (one of the most explicit I
have seen in a while). I edited the batch variables and was able to apply histogram
stretching in batch. I sent the .bcf file to the client.
=====
Model1.gmd:
PAGESIZE 6, 8 INCHES;
CELLSIZE MINIMUM;
PRINTERPAGESIZE 8.5, 11;
MARGINS 0.5, 0.5, 0.5, 0.5;
ORIENTATION PORTRAIT;
PRINTSCALE 100;
WINDOW UNION;
PROJECTION DEFAULT;
AOI NONE;
OPTIMIZE NO;
RASTER {
ID 1;
TITLE "n1_2";
POSITION 1.22222, 1.85556;
FILENAME "d:/work/data/example/2-2.img";
INTERPOLATION NEAREST;
ATHEMATIC;
DATATYPE UNSIGNED8;
DECLARE "Integer";
COMPRESSION UNCOMPRESSED;
COORDINATES MAP;
AOI NONE;
RECODE NO;
CHILD 2;
}
FUNCTION {
ID 2;
TITLE "$n1_2";
POSITION 1.85556, 3.43333;
VALUE "$n1_2";
AREA UNION;
CHILD 3;
}
RASTER {
ID 3;
TITLE "n3_2";
POSITION 1.05556, 4.95556;
FILENAME "d:/work/data/output/2-2.img";
DELETEFILE;
INTERPOLATION NEAREST;
ATHEMATIC;
DATATYPE UNSIGNED8;

DECLARE "Integer";
COMPRESSION UNCOMPRESSED;
COORDINATES MAP;
RECODE NO;
}

Model2.gmd:

PAGESIZE 8.23333, 8 INCHES;
CELLSIZE MINIMUM;
PRINTERPAGESIZE 8.5, 11;
MARGINS 0.5, 0.5, 0.5, 0.5;
ORIENTATION PORTRAIT;
PRINTSCALE 100;
WINDOW UNION;
PROJECTION DEFAULT;
AOI NONE;
OPTIMIZE NO;
TABLE {
ID 1;
TITLE "n1_Read";
POSITION 4.1, 1.63333;
SIZE 0;
DATATYPE DOUBLE;
READ "d:/work/data/output/output.tbl";
CHILD 7;
}
TABLE {
ID 2;
TITLE "n2_Read";
POSITION 5.56666, 1.57778;
SIZE 0;
DATATYPE DOUBLE;
READ "d:/work/data/output/output.tbl";
CHILD 8;
}
TABLE {
ID 3;
TITLE "n3_Read";
POSITION 6.93334, 1.62223;
SIZE 0;
DATATYPE DOUBLE;
READ "d:/work/data/output/output.tbl";
CHILD 9;
}
TABLE {
ID 4;
TITLE "n4_Output";
POSITION 4.17778, 4.62223;
SIZE 0;
DATATYPE DOUBLE;
IMAGENAME "d:/work/data/output/2-2.img";
LAYERNAME "(:Layer_1)";
FIELDNAME "Contrast";
OUTPUT;
}
TABLE {
ID 5;
TITLE "n5_Output";
POSITION 5.66666, 4.64444;
SIZE 0;
DATATYPE DOUBLE;

IMAGENAME "d:/work/data/output/2-2.img";
LAYERNAME "(:Layer_2)";
FIELDNAME "Contrast";
OUTPUT;
}
TABLE {
ID 6;
TITLE "n6_Output";
POSITION 7.16667, 4.66667;
SIZE 0;
DATATYPE DOUBLE;
IMAGENAME "d:/work/data/output/2-2.img";
LAYERNAME "(:Layer_3)";
FIELDNAME "Contrast";
OUTPUT;
}
FUNCTION {
ID 7;
TITLE "$n1_Read";
POSITION 4.03333, 3.13333;
VALUE "$n1_Read";
AREA UNION;
CHILD 4;
}
FUNCTION {
ID 8;
TITLE "$n2_Read";
POSITION 5.53333, 3.14444;
VALUE "$n2_Read";
AREA UNION;
CHILD 5;
}
FUNCTION {
ID 9;
TITLE "$n3_Read";
POSITION 7.02222, 3.15556;
VALUE "$n3_Read";
AREA UNION;
CHILD 6;
}




Output.tbl
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.007843137254901961
0.01568627450980392
0.02352941176470588

0.03137254901960784
0.0392156862745098
0.04705882352941176
0.05490196078431373
0.06274509803921569
0.07058823529411765
0.07843137254901961
0.08627450980392157
0.09411764705882353
0.1019607843137255
0.1137254901960784
0.1215686274509804
0.1294117647058824
0.1372549019607843
0.1450980392156863
0.1529411764705883
0.1607843137254902
0.1686274509803922
0.1764705882352941
0.1843137254901961
0.1921568627450981
0.2
0.207843137254902
0.2156862745098039
0.2274509803921569
0.2352941176470588
0.2431372549019608
0.2509803921568627
0.2588235294117647
0.2666666666666667
0.2745098039215687
0.2823529411764706
0.2901960784313726
0.2980392156862745
0.3058823529411765
0.3137254901960784
0.3215686274509804
0.3333333333333333
0.3411764705882353
0.3490196078431372
0.3568627450980392
0.3647058823529412
0.3725490196078432
0.3803921568627451
0.3882352941176471
0.396078431372549
0.403921568627451
0.4117647058823529
0.4196078431372549
0.4274509803921568
0.4352941176470588
0.4470588235294118
0.4549019607843137
0.4627450980392157
0.4705882352941176
0.4784313725490196
0.4862745098039216
0.4941176470588236
0.5019607843137255
0.5098039215686274
0.5176470588235295
0.5254901960784314
0.5333333333333333

0.5411764705882353
0.5490196078431373
0.5607843137254902
0.5686274509803921
0.5764705882352941
0.5843137254901961
0.592156862745098
0.6
0.6078431372549019
0.615686274509804
0.6235294117647059
0.6313725490196078
0.6392156862745098
0.6470588235294118
0.6549019607843137
0.6666666666666666
0.6745098039215687
0.6823529411764706
0.6901960784313725
0.6980392156862745
0.7058823529411765
0.7137254901960785
0.7215686274509804
0.7294117647058823
0.7372549019607844
0.7450980392156863
0.7529411764705882
0.7607843137254902
0.7686274509803922
0.7803921568627451
0.788235294117647
0.796078431372549
0.803921568627451
0.8117647058823529
0.8196078431372549
0.8274509803921568
0.8352941176470589
0.8431372549019608
0.8509803921568627
0.8588235294117647
0.8666666666666667
0.8745098039215686
0.8823529411764706
0.8941176470588236
0.9019607843137255
0.9098039215686274
0.9176470588235294
0.9254901960784314
0.9333333333333334
0.9411764705882353
0.9490196078431372
0.9568627450980393
0.9647058823529412
0.9725490196078431
0.9803921568627451
0.9882352941176471
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

 

Contributors