Skip to content
Snippets Groups Projects
Commit 024195d0 authored by ik1g19's avatar ik1g19
Browse files

add hybrid functionality

parent f6955270
No related branches found
No related tags found
No related merge requests found
......@@ -19,12 +19,12 @@ import java.net.URL;
public class App {
public static void main( String[] args ) throws Exception {
//Create an image
MBFImage image = ImageUtilities.readMBF(new URL("http://comp3204.ecs.soton.ac.uk/cw/dog.jpg"));
DisplayUtilities.display(image);
MBFImage dog = ImageUtilities.readMBF(new URL("http://comp3204.ecs.soton.ac.uk/cw/dog.jpg"));
MBFImage cat = ImageUtilities.readMBF(new URL("http://comp3204.ecs.soton.ac.uk/cw/cat.jpg"));
MyHybridImages.makeHybrid(image, 5, image, 6);
MBFImage hybrid = MyHybridImages.makeHybrid(dog, 5, cat, 6);
//Display the image
//DisplayUtilities.display(image);
DisplayUtilities.display(hybrid);
}
}
package uk.ac.soton.ecs.ik1g19.hybridimages;
import org.openimaj.image.DisplayUtilities;
import org.openimaj.image.MBFImage;
import org.openimaj.image.processing.convolution.Gaussian2D;
......@@ -28,12 +29,20 @@ public class MyHybridImages {
//Note that the input images are expected to have the same size, and the output
//image will also have the same height & width as the inputs.
float[][] gK = Gaussian2D.createKernelImage(gSigmaToSize(lowSigma), lowSigma).pixels;
float[][] lowGausK = Gaussian2D.createKernelImage(gSigmaToSize(lowSigma), lowSigma).pixels;
float[][] highGausK = Gaussian2D.createKernelImage(gSigmaToSize(highSigma), highSigma).pixels;
MyConvolution gAvg = new MyConvolution(gK);
lowImage.processInplace(gAvg);
MyConvolution gAvgLow = new MyConvolution(lowGausK);
MyConvolution gAvgHigh = new MyConvolution(highGausK);
return lowImage;
lowImage.processInplace(gAvgLow);
DisplayUtilities.display(lowImage);
MBFImage tmpHigh = highImage.process(gAvgHigh);
highImage.subtractInplace(tmpHigh);
DisplayUtilities.display(highImage);
return highImage.add(lowImage);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment