Posted by
Dionysios Lefkaditis on
URL: http://imagej.273.s1.nabble.com/Mixing-custom-and-predefined-features-in-FeatureStack-of-Advanced-Weka-Segmentation-plugin-tp5002334.html
Hello,
I am trying to build a custom feature vector using features provided by AWS and my own in order to classify/segment images using AWS in beanshell. My script is a blend of the two scripts presented in the "Scripting the Trainable Segmentation" page. The script runs ok, but I have problem on how to pass all the slices of custom ImageStack in to a new FeatureStack. As it is at the moment, it only gets the first slice. When I .show() the FeatureStack and I .getSize(), it only returns 1 slice. My script is pasted bellow, but for the sake of being short I have omitted all the classification part. I would greatly appreciate any input.
Thanks in advance
So here it is:
import ij.*;
import ij.process.*;
import trainableSegmentation.*;
import hr.irb.fastRandomForest.*;
// training input image (it could be a stack or a single 2D image)
image = IJ.openImage("/home/dionysis/fermi/media/data/CNH/cnh_multispectral/Denmark_field_1/original images/15/RGB.bmp");
IJ.run(image, "32-bit", "");
H = image.getHeight();
W = image.getWidth();
// corresponding binary labels
labels = IJ.openImage("/home/dionysis/fermi/media/data/CNH/cnh_multispectral/Denmark_field_1/original images/15/MOG.bmp");
//*** Custom features***
cam = NewImage.createByteImage("camera_number", W, H, 1, NewImage.FILL_WHITE);
IJ.run(cam, "32-bit", "");
// the FeatureStackArray contains a FeatureStack for every slice in our original image
featuresArray = new FeatureStackArray(image.getStackSize(), 1, 16, false, 1, 19, null);
features = new FeatureStack(image);
features.addGaussianBlur(20);
features.addLaplacian(5);
customstack = new ImageStack(features.getWidth(), features.getHeight());
customstack.addSlice("originalstd", features.getProcessor(1));
customstack.addSlice("gaussianstd", features.getProcessor(2));
customstack.addSlice("Laplacianstd", features.getProcessor(3));
customstack.addSlice("original", image.getProcessor().duplicate());
customstack.addSlice("camera", cam.getProcessor().duplicate());
customFeaturesImage2 = new ImagePlus("features_std&cust", customstack);
customFeaturesImage2.show();
stack2featstack = new FeatureStack(customFeaturesImage2);
stack2featstack.show();
print(stack2featstack.getSize());
featuresArray.set(stack2featstack, 0);
featuresArray.setEnabledFeatures(stack2featstack.getEnabledFeatures());
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html