CenterForDigitalHumanities / SpectralRTI_Toolkit

Process Spectral RTI Images in ImageJ
GNU General Public License v3.0
1 stars 0 forks source link

Pre-generated images and diffuse light on custom images #96

Open thanneken opened 5 years ago

thanneken commented 5 years ago

I think this is fairly low priority and can wait until the next development phase. When creating PCA Pseudocolor the option to use pregenerated images did not work for me. That's not really a big deal because a PCA Pseudocolor with pregenerated images amounts to the same as a custom image. The problem there, though, is that the custom image option is not creating a diffuse light (light position 00) image along with the static raking, at least not with a two-channel custom image. It may well be working fine with a three-channel custom image (which is much simpler). The way it is supposed to work to create a new Y channel by taking the median value from all the hemisphere captures, then take the two custom channels for Cb and Cr, then convert to RGB, save as TIFF and convert to JP2. It might sound complicated but the function may already be in place because it is used for the PCA Pseudocolor. If it is not easy it can wait.

thehabes commented 4 years ago

This one may be too complicated to get into at this point. I would need more details on how PCA Pseudocolor did not work to track down why that failed for you.

For the custom image option, you should review the stipulations that drive when the diffuse light position is created. In particular, it appears to be driven by this code here

if ((imp.getImageStackSize() == 1)&&(imp.getBitDepth()<24)) {
    if (csRakingDesired) {
        noClobber(projectDirectory+"StaticRaking"+File.separator+projectName+"_"+csProcessName+"_00"+".tiff");
        IJ.save(imp, projectDirectory+"StaticRaking"+File.separator+projectName+"_"+csProcessName+"_00"+".tiff");
        createJp2(projectName+"_"+csProcessName+"_00", projectDirectory);
        toDelete = new File(projectDirectory+"StaticRaking"+File.separator+projectName+"_"+csProcessName+"_00"+".tiff");
        Files.deleteIfExists(toDelete.toPath());
    }
    IJ.run(imp, "8-bit", "");
    IJ.run(imp, "Duplicate...", "title=Cb");
    IJ.run(imp, "Duplicate...", "title=Cr");
    cb = WindowManager.getImage("Cb");
    cr = WindowManager.getImage("Cr");
    cb.hide();
    cr.hide();
} 
else if (imp.getImageStackSize() == 2) {
    IJ.run(imp, "8-bit", "");
    IJ.run(imp, "Stack to Images", "");
    cb = WindowManager.getImage(1);
    cr = WindowManager.getImage(2);
    cb.setTitle("Cb");
    cr.setTitle("Cr");
    cb.hide();
    cr.hide();
} 
else if ((imp.getImageStackSize() > 2)||(imp.getBitDepth()==24)){
    if (imp.getImageStackSize() > 3) {
        IJ.run(imp, "Slice Keeper", "first=1 last=3 increment=1");
        logService.log().info("Only the first three slices in the stack can be used at this time.");
    }
    if (imp.getBitDepth() == 8) {
        IJ.run(imp, "RGB Color", "");
    }
    //create a 00 static diffuse
    if (csRakingDesired) {
        noClobber(projectDirectory+"StaticRaking"+File.separator+projectName+"_"+csProcessName+"_00"+".tiff");
        IJ.save(imp, projectDirectory+"StaticRaking"+File.separator+projectName+"_"+csProcessName+"_00"+".tiff");
        createJp2(projectName+"_"+csProcessName+"_00", projectDirectory);
        toDelete = new File(projectDirectory+"StaticRaking"+File.separator+projectName+"_"+csProcessName+"_00"+".tiff");
        Files.deleteIfExists(toDelete.toPath());
    }
    IJ.run(imp, "RGB to YCbCr stack", "");
    IJ.run("8-bit");
    IJ.run("Stack to Images");
    WindowManager.getImage("Y").close();
    cb = WindowManager.getImage("Cb");
    cr = WindowManager.getImage("Cr");
    cb.hide();
    cr.hide();
}

In the future, you can change these conditionals as desired in the code to suite your needs for when the various source images should be created.