package ij.plugin; import ij.*; import ij.process.*; import ij.gui.*; import ij.io.*; import ij.plugin.PlugIn; import ij.Stack; import java.awt.*; import java.util.*; import java.io.*; import java.net.*; public class stereoTool extends Frame implements PlugIn { ImagePlus sourceImage, bufferImage; ImageProcessor ip = null; int width, height; String title; boolean batch=false; public stereoTool() { /*MenuBar menuBar = new MenuBar(); myMenu = new Menu( "File" ); myMenu.add( new MenuItem( "Exit" )); menuBar.add( myMenu ); setMenuBar( menuBar );*/ SuperCedeConstructor(); // Do not remove this line this.show(); //{{INIT_CONTROLS setLayout(null); setSize(430,270); setTitle("modin's stereoTool"); //}} //{{INIT_MENUS //}} } public void run(String arg) { ImagePlus sourceImage = WindowManager.getCurrentImage(); if (sourceImage==null) { hide(); dispose(); Info.noImage(); return; //FolderButtonClicked( new Event(folderButton,1,folderButton) ); } if (!batch) { this.sourceImage = sourceImage; width = sourceImage.getWidth(); height = sourceImage.getHeight(); title = sourceImage.getTitle(); } } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.setColor(new Color( 64, 128, 128 )); g.fillRect(10,25,310,63); g.fillRect(10,93,310,30); g.fillRect(10,128,310,30); } // ------------------------------------------------------------------------------- // anaglyph2interlaced // ------------------------------------------------------------------------------- protected void A2i_buttonClicked( Event event ) { bufferImage = new ImagePlus("",sourceImage.getImage(),Info.getImageJ()); if ( (bufferImage.getType()!=bufferImage.COLOR_256) && (bufferImage.getType()!=bufferImage.COLOR_RGB) ) { Info.error("This plug-in requires a color anaglyph image."); return; } else Converter.convertToRGBA(bufferImage); Stack st = bufferImage.getStack(); //gets the RED channel byte[] R = (byte[])st.getPixels(1); //gets the BLUE or GREEN channel int channel = 3; if (anatype_choice.getSelectedIndex()==1) channel = 2; byte[] BG = (byte[])st.getPixels(channel); ImagePlus interlacedImage = NewImage.createByteImage("interlaced-"+title, width, height, 0); ImageProcessor interlacedProc = interlacedImage.getProcessor(); byte[] interlaced = (byte[])interlacedProc.getPixels(); // even lines from the red channel, odd lines from the blue/green if ( ana_toggle.getState() ) { for (int y=0;y", Label.CENTER ); //folderLabel.setForeground( new Color( 255, 255, 255 )); //folderLabel.setBackground( new Color( 0, 128, 128 )); //add( folderLabel ); //folderLabel.reshape( (insets().left + 120), (insets().top + 110), 190, 20 ); } private final boolean SuperCedeEvent( Event event ) { if ((event.target == this) && (event.id == Event.WINDOW_DESTROY)) { selectedExit(); return true; } if ((event.target == a2i_button) && (event.id == Event.ACTION_EVENT)) { A2i_buttonClicked( event ); return true; } if ((event.target == p2a_button) && (event.id == Event.ACTION_EVENT)) { P2a_buttonClicked( event ); return true; } if ((event.target == p2i_button) && (event.id == Event.ACTION_EVENT)) { P2i_buttonClicked( event ); return true; } if ((event.target == exit_button) && (event.id == Event.ACTION_EVENT)) { Exit_buttonClicked( event ); return true; } if ((event.target == a2a_button) && (event.id == Event.ACTION_EVENT)) { A2a_buttonClicked( event ); return true; } if ((event.target == folderButton) && (event.id == Event.ACTION_EVENT)) { FolderButtonClicked( event ); return true; } return super.handleEvent( event ); } private final void SuperCedeStart() { } private final void SuperCedeStop() { } // SuperCede End Methods //Menu myMenu; // SuperCede Begin Declarations // Do not remove the Begin and End markers. // The editor will rewrite the contents of this section each time the form is saved. Button a2i_button; Button p2a_button; Choice anatype_choice; Choice anacolor_choice; Checkbox ana_toggle; Button p2i_button; Checkbox int_toggle; Label infoLabel; Label label1; Button exit_button; Button a2a_button; Button folderButton; Label folderLabel; // SuperCede End Declarations //{{DECLARE_CONTROLS //}} //{{DECLARE_MENUS //}} } // SuperCede Begin Form Properties // 3 // 1 2 "modin's stereoTool v1.0" 100000 0 400 0 F F F "Dialog" // 320 225 13238272 0 2147483666 2147483663 // 0 0 1 1 0 "stereoTool" 0 0 0 2 2 0 T T F T F // "" // F F F F F F F F F F F F F // 13 // Button 10 110 10 30 // A 1 "ana2interlaced" T 3 "a2i_button" 2 100 20 4 T T T 1 0 16777215 "Helvetica" 120000 0 700 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" T // Button 110 210 10 30 // A 2 "pair2ana" T 3 "p2a_button" 2 100 20 4 T T T 1 0 16777215 "Helvetica" 120000 0 700 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" T // Choice 10 110 35 56 // A 3 "red/blue|red/green|" F A "" "" "" "" "" 3 "anatype_choice" 2 100 21 4 T T T 0 0 16777215 "Dialog" 100000 0 400 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" F // Choice 110 210 35 56 // A 4 "monochrome|color|" F A "" "" "" "" "" 3 "anacolor_choice" 2 100 21 4 T F T 0 0 16777215 "Dialog" 100000 0 400 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" F // Checkbox 230 310 35 55 // A 5 "toggle" F F A "" "" 3 "ana_toggle" 2 80 20 4 T T F 0 16777215 8421440 "Dialog" 100000 0 400 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" F // Button 10 110 75 95 // A 6 "pair2interlaced" T 3 "p2i_button" 2 100 20 4 T T T 1 0 16777215 "Helvetica" 120000 0 700 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" T // Checkbox 230 310 75 95 // A 7 "toggle" F F A "" "" 3 "int_toggle" 2 80 20 4 T T F 0 16777215 8421440 "Dialog" 100000 0 400 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" F // Label 10 80 200 210 // A 8 "stereoTool v1.0" 0 3 "infoLabel" 2 70 10 4 T T T 1 0 16777215 "Helvetica" 90000 0 400 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" T // Label 10 160 210 220 // A 9 "(c) 1998 by Martin Kaltenbrunner" 0 3 "label1" 2 150 10 4 T T T 1 0 16777215 "Helvetica" 90000 0 400 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" T // Button 260 310 200 220 // A 10 "EXIT" T 3 "exit_button" 2 50 20 4 T T T 1 0 16777215 "Helvetica" 100000 0 700 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" T // Button 210 310 10 30 // A 11 "ana2ana" T 3 "a2a_button" 2 100 20 4 T T T 1 0 16777215 "Helvetica" 120000 0 700 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" T // Button 10 110 110 130 // A 12 "select folder" T 3 "folderButton" 2 100 20 4 T T T 1 0 16777215 "Helvetica" 120000 0 700 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" T // Label 120 310 110 130 // A 13 "" 1 3 "folderLabel" 2 190 20 4 T T F 0 16777215 8421376 "Dialog" 100000 0 400 0 F F F F F F F F F F F F F -1 -1 1 1 F F 0 0 0 0 0 0 0 0 0 "" F // 13 0 1 2 3 4 5 6 7 8 9 10 11 12 // SuperCede End Form Properties // SuperCede Begin Editor Properties // 1 // 3 813 0 T 3 8388736 8421440 T T F T T F T 0 0 0 0 // 0 16777215 // 0 // 0 // SuperCede End Editor Properties