static CImage<double> CImgInv(CImage<double> img) { CImage<double> OutImg = new CImage<double>(img.GetH, img.GetW); double max = img.GetMax(); for (int i = 0; i < img.GetW; i++) { for (int j = 0; j < img.GetH; j++) { OutImg[i, j] = max - img[i, j]; } } return OutImg; }
public static CImage<double> GetDMatrixImg(double[,] dMatrix, out CImage<double> img, int Size, CImage<double> InImg, double sigma, double X0) { CImage<double> dImg = new CImage<double>(Size, Size); img = CImage<double>.MatrixToCImage(dMatrix, Size); SubtractNoiseDisp(img, sigma, X0, InImg); double maxValue = img.GetMax(); dImg = CImage<double>.Norm(img, byte.MaxValue); int threshold = OtsuMethod.GetThreshold(dImg); double originalThrh = maxValue / byte.MaxValue * threshold; Thresholding(img, originalThrh); dImg = CImage<double>.Norm(CImgInv(img), byte.MaxValue); return dImg; }