44 typedef Blob* BlobPtr;
54 #if !defined(_GoalKeeper_Defined_) 227 const uchar* _redChannel,
228 const uchar* _greenChannel,
229 const uchar* _blueChannel
429 float upperFreqBound,
430 bool retainBackground
521 kkuint32 intensityHistBucketsWhiteSpace[8]
556 float& rowCenterWeighted,
557 float& colCenterWeighted
563 float& orientationAngle
603 float& weightedPixelCount,
604 float centralMoments[9],
605 float centralMomentsWeighted[9]
749 void DrawGrid (
float pixelsPerMinor,
768 const Point& endPoint,
773 const Point& endPoint,
1068 void Opening (MaskTypes mask);
1097 Point& rotatedPoint,
1199 void AllocateBlobIds ();
1201 void AllocateImageArea ();
1203 void AllocateFourierMagnitudeTable ();
1205 void CleanUpMemory ();
1208 bool BackgroundPixel (
uchar pixel)
const;
1212 void BuildGaussian2dKernel (
float sigma,
1219 void CalcDialatedValue (
kkint32 row,
1227 bool CompletlyFilled3By3 (
kkint32 row,
1232 void DeleteExistingBlobIds ();
1238 void FillHoleGrow (
kkint32 _row,
1242 bool Fit (MaskTypes mask,
1248 bool ForegroundPixel (
uchar pixel)
const;
1251 uchar Hit (MaskTypes mask,
1257 bool IsThereANeighbor (MaskTypes mask,
1265 bool ThinningSearchNeighbors (
kkint32 x,
1268 uchar m_Matrix22[][3]
1279 void MomentWeighted (
float& m00,
1312 void SmoothImageChannel (
uchar** src,
1317 void SmoothUsingKernel (
Matrix& kernel,
1375 #define _Raster_Defined_ 1396 KKQueue<Raster> (rasterList)
1413 #define _RasterList_Defined_
void Erosion(RasterPtr dest) const
Place into destination a eroded version of this instances image.
RasterPtr BandPass(float lowerFreqBound, float upperFreqBound, bool retainBackground)
Returns a image that is the result of a BandPass using Fourier Transforms.
void ErosionChanged1(MaskTypes mask, kkint32 row, kkint32 col)
static RasterPtr FromSimpleCompression(const uchar *compressedBuff, kkuint32 compressedBuffLen)
Creates a raster from a compressedBuff created by 'SimpleCompression'.
void CentralMoments(float features[9]) const
returns in 'features' the 8 central moments as defined by Hu plus eccentricity in the eight bucket...
RasterListPtr SplitImageIntoEqualParts(kkint32 numColSplits, kkint32 numRowSplits) const
float CenMomentWeighted(kkint32 p, kkint32 q, float ew, float eh) const
RasterPtr ExtractABlobTightly(const BlobPtr blob, kkint32 padding) const
Extracts a specified blob from this image into a tightly bounded image.
RasterPtr CreateFromOrginalImageWithSpecifidBlobsOnly(RasterPtr origImage, BlobListPtr blobs)
Returns a copy of 'origImage' where only the blobs specified in 'blobs' are copied over...
void DrawLine(kkint32 bpRow, kkint32 bpCol, kkint32 epRow, kkint32 epCol, PixelValue pixelVal)
static void RemoveRasterInstance(const RasterPtr r)
void ConnectedComponent(uchar connectedComponentDist)
Raster(const Raster &_raster, kkint32 _row, kkint32 _col, kkint32 _height, kkint32 _width)
Constructs a new Raster using a subset of the specified Raster as its source. The dimensions of the r...
void DrawConnectedPointList(Point offset, const PointList &borderPixs, const PixelValue &pixelValue, const PixelValue &linePixelValue)
void FillBlob(RasterPtr origImage, BlobPtr blob, PixelValue color)
Will paint the specified blob with the specified color.
Point RotateDerivePreRotatedPoint(kkint32 height, kkint32 width, Point &rotatedPoint, float turnAngle) const
void BackgroundPixelTH(uchar _backgroundPixelTH)
RasterConst * RasterConstPtr
Used by the Raster object to identify a distinct blob; where it is in the raster and its unique id...
void BackgroundPixelValue(uchar _backgroundPixelValue)
void Title(const KKStr &_title)
void CalcAreaAndIntensityFeatures(kkint32 &area, float &weightedSize, kkuint32 intensityHistBuckets[8], kkint32 &areaWithWhiteSpace, kkuint32 intensityHistBucketsWhiteSpace[8]) const
Calculates both Intensity Histograms, one not including internal background pixels and one with plus ...
RasterPtr CreateGrayScaleKLT() const
Creates a image using a KLT Transform with the goal of weighting in favor the color channels with gre...
RasterPtr Rotate(float turnAngle)
RasterPtr ToColor() const
void GetPixelValue(kkint32 row, kkint32 col, uchar &r, uchar &g, uchar &b) const
void Erosion(MorphOp::StructureType _structure, kkuint16 _structureSize, kkint32 _backgroundCountTH)
RasterPtr CreateDilatedRaster(MaskTypes mask) const
RasterPtr FastFourier() const
Raster(const KKStr &fileName, bool &validFile)
Constructs a Raster image from by reading an existing image File such as a BMP file.
void CalcCentroid(kkint32 &size, kkint32 &weight, float &rowCenter, float &colCenter, float &rowCenterWeighted, float &colCenterWeighted) const
KKStr ColorChannelToKKStr(ColorChannels c)
bool BackgroundPixel(kkint32 row, kkint32 col) const
RasterPtr CreateErodedImage(MaskTypes mask) const
void DrawLine(kkint32 bpRow, kkint32 bpCol, kkint32 epRow, kkint32 epCol, uchar pixelVal)
uchar BackgroundPixelValue() const
void MaxPixVal(uchar _maxPixVal)
void SetPixelValue(kkint32 row, kkint32 col, uchar pixVal)
virtual RasterPtr AllocateARasterInstance(kkint32 height, kkint32 width, bool color) const
void DrawPointList(const PointList &borderPixs, uchar redVal, uchar greenVal, uchar blueVal)
uchar foregroundPixelValue
BlobListPtr ExtractBlobs(kkint32 dist)
Will extract a list of connected components from this instance.
void DrawCircle(float centerRow, float centerCol, float radius, float startAngle, float endAngle, const PixelValue &pixelValue)
RasterPtr HistogramEqualizedImage(HistogramPtr equalizedHistogram) const
unsigned __int16 kkuint16
16 bit unsigned integer.
uchar * ToCompressor(kkuint32 &compressedBuffLen) const
Compresses the image in Raster using zlib library and returns a pointer to compressed data...
A class that is used by to represent a single image in memory.
void ErodeSpurs()
removes spurs from image.
static void AddRasterInstance(const RasterPtr r)
Supports two dimensional matrices.
RasterPtr HistogramImage(ColorChannels channel) const
void DrawPointList(Point offset, const PointList &borderPixs, uchar redVal, uchar greenVal, uchar blueVal)
float CalcWeightedArea() const
static std::map< RasterPtr, RasterPtr > allocatedRasterInstances
Supports the tracking down of memory leaks in Raster; it will be called every time a new instance of ...
void FourierExtractFeatures(float fourierFeatures[5]) const
void ReduceToMostCompleteBlob(uchar connectedComponentDist)
Locates most complete blob; that is the one with the largest (Height x Width); and removes all other ...
kkint32 foregroundPixelCount
void Initialize(kkint32 _height, kkint32 _width, uchar *_Data, uchar **_Rows, bool _takeOwnership)
Sets an existing instance to specific Raster Data of a image.
void SetPixelValue(ColorChannels channel, kkint32 row, kkint32 col, uchar pixVal)
Raster(const Raster &_raster, MaskTypes _mask, kkint32 _row, kkint32 _col)
Constructs a Raster that will be the same size as the specified '_mask' with the top left specified b...
const KKStr & Title() const
void Erosion(MaskTypes mask)
void WhiteOutBackground()
Sets all pixels that are in the Background Range ov values to BackgroundPixelValue.
RasterPtr ExtractABlob(const BlobPtr blob) const
Extracts a specified blob from this image; useful to extract individual detected blobs.
void SetPixelValue(kkint32 row, kkint32 col, const PixelValue &pixVal)
unsigned __int32 kkuint32
Raster(kkint32 _height, kkint32 _width)
Constructs a blank image with given dimensions; all pixels will be initialized to 0...
static MatrixPtr BuildGaussian2dKernel(float sigma)
Builds a 2d Gaussian kernel.
uchar ForegroundPixelValue() const
uchar backgroundPixelValue
void GetPixelValue(kkint32 row, kkint32 col, PixelValue &p) const
void ReSize(kkint32 _height, kkint32 _width, bool _color)
Lets you resize the raster dimensions; old image data will be lost.
void CalcAreaAndIntensityHistogram(kkint32 &area, kkuint32 intensityHistBuckets[8]) const
Calculates the occurrence of different intensity levels.
RasterPtr Padded(kkint32 padding)
RasterPtr ReduceByFactor(float factor) const
void Edge(RasterPtr dest)
RasterPtr CreateSmoothedFrame()
Used by Raster class and MorphOp derived classes to denote a single pixel location in Raster image...
float * FourierMagArea() const
RasterPtr ExtractChannel(ColorChannels channel)
Will return a gray-scale image consisting of the specified color channel only.
void DrawDot(const Point &point, const PixelValue &color, kkint32 size)
void FillHole(RasterPtr mask)
Fills holes in the image using the 'mask' raster as a work area.
void ForegroundPixelValue(uchar _foregroundPixelValue)
RasterList * RasterListPtr
RasterPtr CreateColorImageFromLabels()
Produces a color image using the 'greenArea' channel, assuming that each unique value will be assigne...
float CentroidCol() const
Used to encode and decode BMP Images.
void DrawLine(kkint32 bpRow, kkint32 bpCol, kkint32 epRow, kkint32 epCol, uchar r, uchar g, uchar b)
HistogramPtr HistogramGrayscale() const
RasterPtr CreateColor() const
RasterPtr SobelEdgeDetector() const
void CalcAreaAndIntensityFeatures(kkint32 &area, float &weightedSize, kkuint32 intensityHistBuckets[8]) const
Calculates both Intensity Histograms, one not including internal background pixels and one with plus ...
void Initialize(kkint32 _height, kkint32 _width, uchar *_redArea, uchar **_red, uchar *_greenArea, uchar **_green, uchar *_blueArea, uchar **_blue, bool _takeOwnership)
Sets an existing instance to specific Raster Data of a image.
void DrawLine(kkint32 bpRow, kkint32 bpCol, kkint32 epRow, kkint32 epCol)
uchar GetPixelValue(ColorChannels channel, kkint32 row, kkint32 col) const
void Dilation(RasterPtr dest) const
void Dilation(MaskTypes mask)
RasterPtr SwapQuadrants() const
const KKStr & FileName() const
ColorChannels ColorChannelFromKKStr(const KKStr &s)
RasterPtr ReduceByEvenMultiple(kkint32 multiple) const
kkint32 BlobId(kkint32 row, kkint32 col) const
Return the ID of the blob that the specified pixel location belongs to.
RasterPtr TightlyBounded(kkuint32 borderPixels) const
unsigned char uchar
Unsigned character.
void SetPixelValue(kkint32 row, kkint32 col, uchar r, uchar g, uchar b)
kkint32 ForegroundPixelCount() const
void DrawLine(kkint32 bpRow, kkint32 bpCol, kkint32 epRow, kkint32 epCol, PixelValue pixelVal, float alpha)
void TakeOwnershipOfAnotherRastersData(Raster &otherRaster)
Will take ownership of 'otherRaster' raster dynamically allocated data and copy its non dynamically a...
RasterPtr FindMagnitudeDifferences(const Raster &r)
Returns an image that reflects the differences between this image and the image supplied in the param...
uchar BackgroundPixelTH() const
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
static void PrintOutListOfAllocatedrasterInstances()
void Edge()
reduces image to edge pixels only.
void Dilation(RasterPtr dest, MaskTypes mask) const
RasterPtr SegmentImage(bool save=false)
RasterPtr HistogramGrayscaleImage() const
static RasterPtr FromCompressor(const uchar *compressedBuff, kkuint32 compressedBuffLen)
Creates a new instance of Raster object from zLib compressed data.
void ErosionChanged(MaskTypes mask, kkint32 row, kkint32 col)
RasterList(const RasterList &rasterList, bool _owner)
void DrawPointList(Point offset, const PointList &borderPixs, const PixelValue &pixelValue)
void Erosion(RasterPtr dest, MaskTypes mask) const
static volatile GoalKeeperPtr goalKeeper
void SetPixelValue(const Point &point, const PixelValue &pixVal)
kkint32 TotPixels() const
kkint32 TotalBackgroundPixels() const
void DrawCircle(const Point &point, kkint32 radius, const PixelValue &color)
Draw a circle who's center is at 'point' and radius in pixels is 'radius' using color 'color'...
RasterPtr CreateSmoothImage(kkint32 maskSize=3) const
PointListPtr DeriveImageLength() const
static RasterPtr CreatePaddedRaster(BmpImage &image, kkint32 padding)
Raster(kkint32 _height, kkint32 _width, bool _color)
Constructs a blank image with given dimensions.
Raster(kkint32 _height, kkint32 _width, const uchar *_Data)
Construct a Raster object using provided raw data.
uchar * GreenArea() const
uchar ** GetSubSet(uchar **_src, kkint32 _row, kkint32 _col, kkint32 _height, kkint32 _width) const
Returns back a two dimension array that is a copy of the specified region in the image.
RasterPtr ExtractUsingMask(RasterPtr mask)
Extracts the pixel locations where the 'mask' images pixel location is a foreground pixel...
void DrawLine(const Point &beginPoint, const Point &endPoint, uchar pixelVal)
void FindBoundingBox(kkint32 &tlRow, kkint32 &tlCol, kkint32 &brRow, kkint32 &brCol) const
void CalcAreaAndIntensityFeatures16(kkint32 &area, float &weighedSize, kkuint32 intensityHistBuckets[16])
virtual RasterPtr AllocateARasterInstance(const Raster &_raster, kkint32 _row, kkint32 _col, kkint32 _height, kkint32 _width) const
HistogramPtr Histogram(ColorChannels channel) const
static volatile bool rasterInitialized
bool AreThereEdgePixels(kkint32 edgeWidth)
returns true if there are any foreground pixels within 'edgeWidth' pixels of the top, bottom, left, or right edges of the image.
void CalcAreaAndIntensityHistogramWhite(kkint32 &area, kkuint32 intensityHistBuckets[8])
Calculates a Intensity Histogram including Background pixels in the image.
Maintains a list of blobs.
RasterPtr ThresholdInHSI(float thresholdH, float thresholdS, float thresholdI, float distance, const PixelValue &flagValue)
void ComputeCentralMoments(kkint32 &foregroundPixelCount, float &weightedPixelCount, float centralMoments[9], float centralMomentsWeighted[9]) const
Computes central moments; one set where each pixel is treated as 1 or 0(Foreground/Background) and th...
Raster(const BmpImage &_bmpImage)
Constructs a Raster from a BMP image loaded from disk.
void CentralMomentsWeighted(float features[9]) const
Similar to 'CentralMoments' except each pixel position is weighted by its intensity value...
Raster(kkint32 _height, kkint32 _width, uchar *_Data, uchar **_Rows)
Construct a raster object that will utilize a image already in memory.
KKStr & operator=(const KKStr &src)
Base class for all Morphological operations.
virtual RasterPtr AllocateARasterInstance(const Raster &r) const
void PaintFatPoint(kkint32 row, kkint32 col, const PixelValue pv, float alpha)
Container object used to maintaining a list of pixel locations.
kkint32 MemoryConsumedEstimated() const
void Dilation(MorphOp::StructureType _structure, kkuint16 _structureSize, kkint32 _foregroundCountTH)
void DrawCircle(float centerRow, float centerCol, float radius, const PixelValue &pixelValue)
void DrawLine(const Point &beginPoint, const Point &endPoint, const PixelValue &pixelVal)
Raster(const Raster &_raster)
Copy Constructor.
void DrawPointList(const PointList &borderPixs, const PixelValue &pixelValue)
void Opening(MaskTypes mask)
RasterPtr HistogramEqualizedImage() const
float CentroidRow() const
RasterPtr CreateGrayScaleKLTOnMaskedArea(const Raster &mask) const
Same as 'CreateKLT' except it will only take into account pixels specified by the 'mask' image...
RasterPtr ReversedImage()
void DrawFatLine(Point startPoint, Point endPoint, PixelValue pv, float alpha)
void FileName(const KKStr &_fileName)
bool ForegroundPixel(kkint32 row, kkint32 col) const
RasterPtr CreateGrayScale() const
double CenMoment(kkint32 colMoment, kkint32 rowMoment, double centerCol, double centerRow) const
void PaintPoint(kkint32 row, kkint32 col, const PixelValue &pv, float alpha)
uchar * SimpleCompression(kkuint32 &buffLen) const
Compresses the image in Raster using a simple Run length algorithm and returns a pointer to compresse...
RasterPtr ThinContour() const
void DrawLine(kkint32 bpRow, kkint32 bpCol, kkint32 epRow, kkint32 epCol, uchar r, uchar g, uchar b, float alpha)
RasterPtr Transpose() const
RasterPtr CreateColorWithBlobsLabeldByColor(BlobListPtr blobs)
Returns image where each blob is labeled with a different color.
void WeOwnRasterData(bool _weOwnRasterData)
Raster(kkint32 _height, kkint32 _width, const uchar *_redChannel, const uchar *_greenChannel, const uchar *_blueChannel)
Construct a Color Raster object using provided raw data,.
void DrawGrid(float pixelsPerMinor, kkuint32 minorsPerMajor, const PixelValue &hashColor, const PixelValue &gridColor)
RasterPtr CreateDilatedRaster() const
void FollowContour(float countourFreq[5]) const
RasterPtr CreateGaussianSmoothedImage(float sigma) const
Used to manage the construction of a Histogram.
RasterPtr FastFourierKK() const
void ErosionBoundary(MaskTypes mask, kkint32 blobrowstart, kkint32 blobrowend, kkint32 blobcolstart, kkint32 blobcolend)
void ConnectedComponent8Conected()
static void FinalCleanUp()
Used by the Raster Class to represent the contents of one pixel.
void CalcOrientationAndEigerRatio(float &eigenRatio, float &orientationAngle)
RasterPtr StreatchImage(float rowFactor, float colFactor) const
void ForegroundPixelCount(kkint32 _foregroundPixelCount)
void Divisor(kkint32 _divisor)
void FillRectangle(kkint32 tlRow, kkint32 tlCol, kkint32 brRow, kkint32 brCol, const PixelValue &fillColor)
RasterPtr BinarizeByThreshold(uchar min, uchar max) const
RasterPtr CreateSmoothedMediumImage(kkint32 maskSize) const
void Closing(MaskTypes mask)
uchar GetPixelValue(kkint32 row, kkint32 col) const