RegionMask2D.java
Go to the documentation of this file.00001 package theba.core;
00002
00008 public class RegionMask2D extends RegionMask {
00009
00010 short[] mask;
00011
00012 short id;
00013
00014 public RegionMask2D(short[] mask, int width, int height) {
00015 super();
00016 this.id = 0xff;
00017 this.mask = mask;
00018 this.width = width;
00019 this.height = height;
00020 this.depth = 1;
00021 }
00022
00023 public Stack getVolume() {
00024 return null;
00025 }
00026
00027 @Override
00028 public boolean isSet(int xp, int yp, int zp) {
00029 if (xp < 0 || yp < 0 || xp >= width || yp >= height || zp != 0)
00030 return false;
00031 return mask[xp + yp * width] != 0;
00032 }
00033
00034 @Override
00035 public short getPixelAt(int xp, int yp, int zp) {
00036 if (xp < 0 || yp < 0 || xp >= width || yp >= height || zp != 0)
00037 throw new ArrayIndexOutOfBoundsException("Wrong coord " + xp + " ,"
00038 + yp + "," + zp);
00039 return mask[xp + yp * width];
00040 }
00041
00042 @Override
00043 public int getWidth() {
00044 return width;
00045 }
00046
00047 @Override
00048 public int getHeight() {
00049 return height;
00050 }
00051
00052 @Override
00053 public int getDepth() {
00054 return depth;
00055 }
00056
00057 }