public void TestCroppedSize() { ImageInfo imInf = new ImageInfo(PATH_160_120_RGB); // test when size < PROC_IMAGE_SIZE Size testSize = new Size(160, 120); Size newSize = imInf.croppedSize(testSize); Size wantedSize = new Size(160, 120); Assert.AreEqual(wantedSize,newSize); Console.WriteLine("wantedArea: {0}, newArea: {1}, newSize: {2}, origSize: {3}", wantedSize.Height*wantedSize.Width,newSize.Height*newSize.Width, newSize, testSize); // test when size > PROC_IMAGE_SIZE testSize = new Size(640, 480); newSize = imInf.croppedSize(testSize); wantedSize = new Size(320, 240); Console.WriteLine("wantedArea: {0}, newArea: {1}, newSize: {2}, origSize: {3}", wantedSize.Height * wantedSize.Width, newSize.Height * newSize.Width, newSize, testSize); Assert.IsTrue(wantedSize.Height*wantedSize.Width >= newSize.Height*newSize.Width); testSize = new Size(1920, 1080); newSize = imInf.croppedSize(testSize); wantedSize = new Size(320, 240); Console.WriteLine("wantedArea: {0}, newArea: {1}, newSize: {2}, origSize: {3}", wantedSize.Height * wantedSize.Width, newSize.Height * newSize.Width, newSize, testSize); Assert.IsTrue(wantedSize.Height * wantedSize.Width >= newSize.Height * newSize.Width); testSize = new Size(1600, 900); newSize = imInf.croppedSize(testSize); wantedSize = new Size(320, 240); Console.WriteLine("wantedArea: {0}, newArea: {1}, newSize: {2}, origSize: {3}", wantedSize.Height * wantedSize.Width, newSize.Height * newSize.Width, newSize, testSize); Assert.IsTrue(wantedSize.Height * wantedSize.Width >= newSize.Height * newSize.Width); }
public void TestDeepCopyCOns() { ImageInfo from = new ImageInfo(PATH_160_120_RGB); from.getHist(); from.getImb(); from.getImF(); ImageInfo to = new ImageInfo(from); from.Dispose(); from = null; Debug.WriteLine("B:{0},F:{1}, W:{2}, H:{3}, HISTMEAN:{4}, P:{5}", to.getImb().Length, to.getImF().Length, to.Width, to.Height, to.getHist().Mean, to.getPath()); }
/// <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; }
public void TestBadContrast() { int numImages = pathes.Length; ImageInfo[] images = new ImageInfo[numImages]; for (int i = 0; i < numImages; i++) { images[i] = new ImageInfo(pathes[i]); } BadContrast bc; bc = new BadContrast(images); bc.run(); }
public void TestBitExactLoadPictures() { int numImages = pathes.Length; ImageInfo[] images = new ImageInfo[numImages]; for (int i = 0; i < numImages; i++) images[i] = new ImageInfo(pathes[i]); // int w=24, j=22; BitExact be = new BitExact(images); //be.equalImages(w, j); //Debug.WriteLine("{0} \n {1}", images[w].getPath(), images[j].getPath()); be.run(); Debug.WriteLine("{0}", "OK!!!"); }
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); }
public BadContrast(ImageInfo[] images) { this.images = images; matches = new List<string>(); num_images = images.Length; }
//default constructor, set & init variables public BitExact(ImageInfo[] images) { matches = new List<List<string>>(); setImages(images); }
private int similarSizes(out ImageInfo first,out ImageInfo second, int i, int j) { int size = images[i].Height * images[i].Width; int size2 = images[j].Height * images[j].Width; if ( (double)size / size2 != 1.0) { if (size2 < size) { first = new ImageInfo(images[i], new Size(images[j].Width, images[j].Height)); second = new ImageInfo(images[j], new Size(images[j].Width, images[j].Height)); return size2; } else { first = new ImageInfo(images[i], new Size(images[i].Height, images[i].Width)); second = new ImageInfo(images[j], new Size(images[i].Height, images[i].Width)); return size; } } else { //first = new ImageInfo(images[i], new Size(images[i].Height, images[i].Width)); //second = new ImageInfo(images[j], new Size(images[i].Height, images[i].Width)); first = images[i]; second = images[j]; } return size; }
//set path of images, and set relevant variables public void setImages(ImageInfo[] images) { this.images = images; numImages = images.Length; initResults(); checkedImages = new bool[numImages]; propotions = new Propotion[numImages]; }
/// <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; }
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)); }
/// <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()); }
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(); } }
private void startLoadingImages() { for (int i = 0; i < _images.Length; i++) { try { _images[i] = new ImageInfo(_task.ImagePathes[i]); } catch (ThreadAbortException) { Thread.ResetAbort(); return; } catch (Exception e) { throw e; } _loadingImagesStatus = (int)(((float)(i + 1) * 100) / _images.Length); } }
public void TestDIspose() { string path = @"C:\Users\Daniel\Desktop\iPhone Photos\"; string[] pathes = Directory.GetFiles(path, "*.jpg", SearchOption.AllDirectories); ImageInfo[] images = new ImageInfo[pathes.Length]; for (int i = 0; i < images.Length; i++) { images[i] = new ImageInfo(pathes[i]); } Thread.Sleep(5000); Debug.WriteLine("Start Dispose"); for (int i = 0; i < images.Length; i++) { images[i].Dispose(); } Thread.Sleep(4000); Debug.WriteLine("End Dispose"); Thread.Sleep(5000); }
public void TestImageInfoCopyResizeConstructor() { string path = @"C:\Users\Yossi\Dropbox\Project\BitExact Pictures\pic450X800.jpg"; ImageInfo origIm = new ImageInfo(path); ImageInfo origIm2 = new ImageInfo(origIm, new Size(origIm.Width/2, origIm.Height/2)); ImageInfo.writeImage(origIm, @"C:\Users\Yossi\Dropbox\Project\BitExact Pictures\" + "orig.jpg"); ImageInfo.writeImage(origIm2, @"C:\Users\Yossi\Dropbox\Project\BitExact Pictures\" + "orig2.jpg"); }
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"); }
/// <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 TestgetHist() { ImageInfo imInf = new ImageInfo(PATH_160_120_RGB); AForge.Math.Histogram hist = imInf.getHist(); Console.WriteLine("{0} {1} {2} {3} {4} {5}\n", hist.Max, hist.Min, hist.Mean, hist.StdDev, hist.TotalCount, hist.Median); int[] histVal = hist.Values; for (int i = 0; i < histVal.Length; i++) { Console.Write("{0} ", histVal[i]); } }