private static int[,] BWHitMissProcess(Bitmap img, int[,] FirstStructureElement, int[,] SecondStructureElement) { int[,] temp = new int[img.Height, img.Width]; int[,] result = new int[img.Height, img.Width]; //Bitmap read binary images as 0/255 int[,] original = Helpers.Image2BinaryArray(img); int[,] inverted = MoreHelpers.InvertBinaryArray(original); temp = MorphOperationsCall.MorphOperationArray(original, MorphOp.Erode, FirstStructureElement); result = MorphOperationsCall.MorphOperationArray(inverted, MorphOp.Erode, SecondStructureElement); result = result.ArrayMultElements(temp); //make result saveble for (int i = 0; i < result.GetLength(0); i++) { for (int j = 0; j < result.GetLength(1); j++) { if (result[i, j] == 1) { result[i, j] = 255; } } } return(result); }
public static void AdaptiveThreshold(Bitmap img, int[,] structureElement) { //even don`t know make check if b&w image and transform before morph operation //with 8bpp image seems working fine //MorphOperationsCall.MorphOperation(image, MorphOp.imOpen, structureElement); Bitmap imOpen = MorphOperationsCall.MorphOperationBitmap(img, MorphOp.imOpen, structureElement); ThresholdShapkaProcess(imOpen, img, "_adaptiveThreshold", true); }