/** Marvin Project <2007-2009> Initial version by: Danilo Rosetto Munoz Fabio Andrijauskas Gabriel Ambrosio Archanjo site: http://marvinproject.sourceforge.net GPL Copyright (C) <2007> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.marvinproject.image.segmentation.imageSlicer; import java.io.File; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import javax.imageio.ImageIO; import javax.swing.JOptionPane; import marvin.gui.MarvinFilterWindow; import marvin.image.MarvinImage; import marvin.image.MarvinImageMask; import marvin.performance.MarvinPerformanceMeter; import marvin.plugin.MarvinAbstractImagePlugin; import marvin.util.MarvinAttributes; import marvin.util.MarvinErrorHandler; import marvin.util.MarvinFileChooser; /** * Image Slicer plug-in. * @author Hugo Henrique Slepicka * @version 1.1 05/11/2008 */ public class ImageSlicer extends MarvinAbstractImagePlugin { private MarvinAttributes attributes; private MarvinPerformanceMeter performanceMeter; private DecimalFormat df = new DecimalFormat("000"); public void load() { attributes = getAttributes(); attributes.set("txtLines", 1); attributes.set("txtCols", 1); performanceMeter = new MarvinPerformanceMeter(); } public void process ( MarvinImage a_imageIn, MarvinImage a_imageOut, MarvinAttributes a_attributesOut, MarvinImageMask a_mask, boolean a_previewMode ) { int conti, contx, conty, col, line, r, g, b, lines, cols, limitl, limitc; //Initialize the variables... col = line = conti = contx = conty = 0; //Get the values from objects... lines = Integer.parseInt(attributes.get("txtLines").toString()); cols = Integer.parseInt(attributes.get("txtCols").toString()); //Get the image width and height... int width = a_imageIn.getWidth(); int height = a_imageIn.getHeight(); //Set the vertical and horizontal limits of the images limitl = (height/lines); limitc = (width/cols); if(a_previewMode != true){ //Creates the list to store the marvin Images of the sliced image... List listaImgs = new ArrayList(); //Sets the default image to the images on the list... for(int x=0;x<(lines*cols);x++){ listaImgs.add(new MarvinImage(limitc, limitl)); } //Creates the Performance Meter... performanceMeter.enableProgressBar("Image Slicer", (lines*cols*limitc*limitl)); int x,y=0; for(line=0;line