Commit 849b916d authored by Andrey Filippov's avatar Andrey Filippov

added imagej macros

parent a602300e
This diff is collapsed.
macro "fiji_scoremaps" {
saveSettings;
template_dir="/media/elphel/SSD3-4GB/lwir16-proc/berdich/annotations/collages/pattern-matching";
//template_file= "object3_black_half_7-24x24.tiff"; // blurred
template_file="object3_black_48_gb5-0.33_32x32.tiff"; // sharper circle
// template_file="object3_black_48-0.33_32x32.tiff"; // sharp circle
soure_dir="/media/elphel/SSD3-4GB/lwir16-proc/berdich/annotations/collages/pattern-matching/exported_layers_on_grey";
// scoremaps_directory="/media/elphel/SSD3-4GB/lwir16-proc/berdich/annotations/collages/pattern-matching/scoremaps";
scoremaps_directory="/media/elphel/SSD3-4GB/lwir16-proc/berdich/annotations/collages/pattern-matching/scoremaps_medium";
// scoremaps_directory="/media/elphel/SSD3-4GB/lwir16-proc/berdich/annotations/collages/pattern-matching/scoremaps_sharp";
suffix="-scoremap";
create_scoremap("L3-1691017293_032075-7285_82.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017293_032075-7285_82-rot-shift.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017288_801308.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017293_032075.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017286_416693.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017285_820540.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017285_262848.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017284_609002.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017284_070541.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017283_609002.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
function create_scoremap (src_file, template, template_dir, src_dir, score_dir, suffix) {
open(template_dir+"/"+template);
selectImage(template);
open(src_dir+"/"+src_file);
selectImage(src_file);
source_width=getWidth();
source_height=getHeight();
run("32-bit");
run("Subtract...", "value=128");
run("Window/Level...");
run("Enhance Contrast", "saturated=0.35");
run("Compute ScoreMap", "template="+template+" image=" + src_file+" method=[Normalised cross-correlation] score_threshold=0.9");
close(); // thresholded result
run("Canvas Size...", "width="+source_width+" height="+source_height+" position=Center zero");
saveAs("Tiff", score_dir + "/"+src_file+suffix+".tiff");
close(); // saved result
close(); // source file
close(); // template file
}
restoreSettings;
}
// /home/elphel/git/imagej-elphel/ij_macros/fiji_scoremaps.txt
macro "fiji_get_points" {
saveSettings;
s = selectionType();
if ( s == -1 ) {
exit("There was no selection.");
} else if( s != 10 ) {
exit("The selection wasn't a point selection.");
} else {
getSelectionCoordinates(xPoints,yPoints);
x = xPoints[0];
y = yPoints[0];
showMessage("Got coordinates ("+x+","+y+")");
showMessage("Got points:" + xPoints.length);
for (i = 0; i < xPoints.length; i++){
print (i, xPoints[i], yPoints[i]);
}
}
/*
2180, 2428 -16: 2164, 2412
3441, 2561
6: 2185, 2431 ( 2180, 2427 - offsest by 5?
7: 2175, 3351
2299, 3241
template_dir="/media/elphel/SSD3-4GB/lwir16-proc/berdich/annotations/collages/pattern-matching";
template_file="object3_black_half_7-24x24.tiff";
soure_dir="/media/elphel/SSD3-4GB/lwir16-proc/berdich/annotations/collages/pattern-matching/exported_layers_on_grey";
scoremaps_directory="/media/elphel/SSD3-4GB/lwir16-proc/berdich/annotations/collages/pattern-matching/scoremaps";
suffix="-scoremap";
create_scoremap("L3-1691017288_801308.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017293_032075.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017286_416693.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017285_820540.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017285_262848.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017284_609002.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017284_070541.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
create_scoremap("L3-1691017283_609002.jpeg", template_file, template_dir, soure_dir, scoremaps_directory, suffix);
function create_scoremap (src_file, template, template_dir, src_dir, score_dir, suffix) {
open(template_dir+"/"+template);
selectImage(template);
open(src_dir+"/"+src_file);
selectImage(src_file);
source_width=getWidth();
source_height=getHeight();
run("32-bit");
run("Subtract...", "value=128");
run("Wi8dow/Level...");
run("Enhance Contrast", "saturated=0.35");
run("Compute ScoreMap", "template="+template+" image=" + src_file+" method=[Normalised cross-correlation] score_threshold=0.9");
close(); // thresholded result
run("Canvas Size...", "width="+source_width+" height="+source_height+" position=Center zero");
saveAs("Tiff", score_dir + "/"+src_file+suffix+".tiff");
close(); // saved result
close(); // source file
close(); // template file
}
*/
restoreSettings;
}
// /home/elphel/git/imagej-elphel/ij_macros/fiji_scoremaps.txt
macro "goto_coordinates" {
saveSettings;
width=300;
height=200;
xc=0; yc=0;
Dialog.create("My dialog"); // ("Go to selected coordinates. Creates rectangular selection" );
Dialog.addNumber("Selection center X",xc);
Dialog.addNumber("Selection center Y",yc);
Dialog.addNumber("Selection width", width);
Dialog.addNumber("Selection height", height);
Dialog.show();
xc = Dialog.getNumber();
yc = Dialog.getNumber();
width = Dialog.getNumber();
height = Dialog.getNumber();
print("xc="+xc+", yc="+yc+", width="+width+", height="+height);
makeRectangle(xc-width/2, yc-height/2, width, height);
run("To Selection");
restoreSettings;
}
macro "make_snapshots" {
saveSettings;
// copy lines to match required objects and put actual coordinates/names
// (no spaces) below using kate's <cntrl><shift>b mode
// To run - open file in imagej, go to Plugins->Macros->Run and select this file (should have .txt extension)
//
subdir = "objects"
Dialog.create("objects snapshots "); // ("Go to selected coordinates. Creates rectangular selection" );
Dialog.addString("Subdirectory name",subdir);
Dialog.show();
subdir = Dialog.getString();
makeSnapshot( 2456, 6458 , 150, 150, "_M", subdir);
makeSnapshot( 4790, 9484 , 150, 150, "01", subdir);
makeSnapshot( 4624, 10291, 150, 150, "02", subdir);
makeSnapshot( 4642, 12968, 150, 150, "03", subdir);
makeSnapshot( 4734, 11946, 150, 150, "04", subdir);
makeSnapshot( 5266, 11618, 150, 150, "05", subdir);
makeSnapshot( 4865, 5362 , 150, 150, "06", subdir);
makeSnapshot( 4805, 7027 , 150, 150, "07", subdir);
makeSnapshot( 4791, 8698 , 150, 150, "08", subdir);
makeSnapshot( 4358, 5972 , 150, 150, "09", subdir);
makeSnapshot( 4785, 12213, 150, 150, "10", subdir);
makeSnapshot( 5620, 11280, 150, 150, "11", subdir);
function makeSnapshot(xc, yc, width, height, suffix, subdir) {
base_directory=getInfo("image.directory");
directory = base_directory+"/"+subdir;
filename=getInfo("image.filename")+"-"+suffix;
makeRectangle(xc-width/2, yc-height/2, width, height);
run("Duplicate...", " ");
print("saving object snapshot to: "+ directory+"/"+filename+"-"+xc+"_"+yc+"_"+width+"_"+height+".tiff");
File.makeDirectory(directory);
saveAs("Tiff", directory+"/"+filename+"-"+xc+"_"+yc+"_"+width+"_"+height+".tiff");
saveAs("Jpeg", directory+"/"+filename+"-"+xc+"_"+yc+"_"+width+"_"+height+".jpeg");
close();
}
restoreSettings;
}
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