/** * Cells_filter.java * Created on 25 October 2020 by Manuel Guillermo Forero-Vargas * e-mail: mgforero@yahoo.es * * Function: This plug-in seeks to eliminate the false cells found, comparing the * difference in between the minimum and maximum level of grey in each cell. If * the value is below a threshold, the cell is eliminated. Finally all the cells * are relabelled. * * Input: 8 and 16 bit images. The labelled image is modified. * Output: The labelled image * * Copyright (c) 2020 by Manuel Guillermo Forero-Vargas * e-mail: mgforero@yahoo.es * * This plugin is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * 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 plugin; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ import ij.*; import ij.process.*; import ij.gui.*; import ij.plugin.*; public class Cells_filter implements PlugIn { @Override public void run(String arg) { boolean flLabel,relabel=false; boolean fNumber=true; int a,i,j,minDif=100,minmodifiedlabel,type,z; short[] pixelsLabel; //---------------------------------------------------------------------- //Gets the image to be processed and the mask image int[] wList=ij.WindowManager.getIDList(); if (wList==null||wList.length<2) { ij.IJ.showMessage("Cell filter","This plugin requires two iimages."); return; } String[] titles=new String[wList.length]; for (i=0;inumRegions) numRegions=pixelsLabel[i]; } numRegions++; //---------------------------------------------------------------------- int[] labels=new int[numRegions];//Table of labels double[] entropyLabels=new double[numRegions];//Entropy of each labeled region double[][] histNorm=new double[numRegions][256];//Histogram of each labeled regionn int[] minLabels=new int[numRegions];//Minimum of each labeled region int[] maxLabels=new int[numRegions];//Maximum of each labeled region int[] sizeLabels=new int[numRegions];//Size of each labeled region minmodifiedlabel=numRegions; //Gets the minimum and maximum grey level of each labelled region //Initialises table of of min labels for(i=1;ia) minLabels[pixelsLabel[i]]=a; if(maxLabels[pixelsLabel[i]]