public void TestConv2() { int[,] kernel = { { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 } }; ImageInfo imOrig = new ImageInfo(PATH_485_405_RGB); ImageInfo convIm = ImageInfo.conv2(imOrig, kernel); ImageInfo.writeImage(convIm, PATH_TEST_RES); ImageInfo.writeImage(imOrig, PATH_TEST_RES0); Console.WriteLine("{0} {1}", imOrig.getIm().Height, imOrig.getIm().Width); Console.WriteLine("{0} {1}", convIm.getIm().Height, convIm.getIm().Width); imOrig.conv2(kernel); ImageInfo.writeImage(imOrig, PATH_TEST_RES1); Console.WriteLine("{0} {1}", imOrig.getIm().Height, imOrig.getIm().Width); }
/// <summary> /// DeepCopy Constructor /// </summary> /// <param name="from">Copied Source</param> public ImageInfo(ImageInfo from) { _disposed = false; // copy path _path = from.getPath(); // copy gray image _imGray = new Bitmap(from.getIm()); // copy histogram _hist = from.getHist() == null ? null : copyHist(from.getHist()); // copy _imf if (from.getImF() != null) { _imf = new float[from.getImF().Length]; from.getImF().CopyTo(_imf, 0); } else { _imf = null; } // copy _imb if (from.getImF() != null) { _imb = new byte[from.getImb().Length]; from.getImb().CopyTo(_imb, 0); } else { _imb = null; } // copy size _width = from.Width; _height = from.Height; }
/// <summary> /// Copyies _imGray with newSize, updates size and and null's the rest of the valeus /// </summary> /// <param name="origIm"></param> /// <param name="newSize"></param> public ImageInfo(ImageInfo origIm, Size newSize) { _disposed = false; _imGray = new Bitmap(origIm.getIm(), newSize); _hist = null; _imf = null; _imb = null; _path = null; _width = newSize.Width; _height = newSize.Height; }
/// <summary> /// writes a jpg formated image from imInfo.getIm() into path /// ****** IF EXISTS, WILL OVERWRITE THE image in path******* /// </summary> /// <param name="imInf">the wanted image to save im imInf.getPath() </param> public static void writeImage(ImageInfo imInf, string path) { writeImage(path, imInf.getIm()); }
/// <summary> /// writes a jpg formated image from imInfo.getIm() into imInf.getPath() /// ****** IF EXISTS, WILL OVERWRITE THE imInf.getPath() image ******* /// </summary> /// <param name="imInf">the wanted image to save im imInf.getPath() </param> public static void writeImage(ImageInfo imInf) { writeImage(imInf.getPath(), imInf.getIm()); }
/// <summary> /// runs a two dimentional convolution on im, /// where f is im and g is filter /// </summary> /// <param name="im">f(t)</param> /// <param name="kernel">g(u-t)</param> /// <returns>a new instance of ImageInfo</returns> public static ImageInfo conv2(ImageInfo im, int[,] kernel) { ImageInfo convIm = new ImageInfo(im.getIm()); Convolution filter = new Convolution(kernel); filter.ApplyInPlace(convIm.getIm()); return convIm; }
public void TestoirgIm2grayCropped() { ImageInfo imInf = new ImageInfo(PATH_485_405_RGB); Bitmap gray = imInf.getIm(); ImageInfo.writeImage(PATH_TEST_RES, gray); Console.WriteLine("oirgIm2grayCropped results are in testRes.jpg\n"); }
public void TestgetImf() { ImageInfo im = new ImageInfo(PATH_160_120_RGB); float[] imf = im.getImF(); Console.WriteLine(" {0} {1} {2} {3}\n", imf.Length, im.getIm().Width * im.getIm().Height, imf.Min(), imf.Max()); Assert.IsTrue(imf.Max() <= 1 && imf.Min() >= 0 && imf.Length == (im.getIm().Width * im.getIm().Height)); }
public void TestgetImb() { ImageInfo im = new ImageInfo(PATH_160_120_RGB); byte[] imb = im.getImb(); for (int i = 0; i < im.getIm().Width; i++) { for (int j = 0; j < im.getIm().Height; j++) { Console.Write("{0} ", imb[i * im.getIm().Height + j]); } Console.WriteLine(); } }