-
-
Save joshdoe/885319 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ij.IJ; | |
import ij.ImagePlus; | |
import ij.ImageStack; | |
import ij.plugin.filter.PlugInFilter; | |
import ij.process.ImageProcessor; | |
public class JoshD_Deinterlace implements PlugInFilter { | |
protected ImagePlus image; | |
public int setup(String arg, ImagePlus image) { | |
this.image = image; | |
return DOES_ALL | NO_CHANGES; | |
} | |
public void run(ImageProcessor ip) { | |
int width = image.getWidth(), height = image.getHeight(); | |
ImageStack stack = image.getStack(); | |
ImageStack out = new ImageStack(width / 2, height / 2); | |
for (int slice = 1; slice <= stack.getSize(); slice++) { | |
ip = stack.getProcessor(slice); | |
Object pixels = ip.getPixels(); | |
ImageProcessor ip1 = ip.createProcessor(width / 2, height / 2); | |
Object pixels1 = ip1.getPixels(); | |
ImageProcessor ip2 = ip.createProcessor(width / 2, height / 2); | |
Object pixels2 = ip2.getPixels(); | |
for (int y = 0; y < height/2; y++) { | |
for (int x = 0; x < width / 2; x++) { | |
ip1.set(x, y, ip.get(x*2, y*2)); | |
ip2.set(x, y, ip.get(x*2, y*2+1)); | |
} | |
} | |
out.addSlice("", ip1); | |
out.addSlice("", ip2); | |
IJ.showProgress(slice, stack.getSize()); | |
} | |
new ImagePlus("Deinterleaved and Decimated " + image.getTitle(), out).show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment