InternalRegionDescriptor.java

Go to the documentation of this file.
00001 package theba.descriptors;
00002 
00003 import theba.core.ImageFunctions;
00004 import theba.core.RegionDescriptor;
00005 import theba.core.RegionMask;
00006 
00007 public class InternalRegionDescriptor implements RegionDescriptor {
00008 
00009         public Object measure(RegionMask mask) {
00010                 short[] m = new short[mask.getWidth() * mask.getHeight()];
00011 
00012                 for (int x = 0; x < mask.getWidth(); x++)
00013                         for (int y = 0; y < mask.getHeight(); y++)
00014                                 if (mask.isSet(x, y, 0))
00015                                         m[x + y * mask.getWidth()] = 1;
00016 
00017                 ImageFunctions.floodFill2D(0, 0, mask.getWidth(), mask.getHeight(), m,
00018                                 (short) 1);
00019                 int count = 0;
00020                 for (int x = 0; x < mask.getWidth(); x++) {
00021                         for (int y = 0; y < mask.getHeight(); y++) {
00022                                 if (m[x + y * mask.getWidth()] == 0) {
00023                                         count++;
00024                                         ImageFunctions.floodFill2D(x, y, mask.getWidth(), mask
00025                                                         .getHeight(), m, (short) 1);
00026                                 }
00027                         }
00028                 }
00029                 return count;
00030         }
00031 
00032         public String getName() {
00033                 return "Internal region count";
00034         }
00035 
00036         public String getAbout() {
00037                 return "The amount of internal regions";
00038         }
00039 
00040         public boolean does() {
00041                 return false;
00042         }
00043 
00044         public boolean isNumeric() {
00045                 return true;
00046         }
00047 
00048         public boolean does3D() {
00049                 // TODO Auto-generated method stub
00050                 return false;
00051         }
00052 
00053 }

Generated on Fri Nov 13 08:57:07 2009 for Theba by  doxygen 1.6.1