private void ImageCleanup(Bitmap inBmp) { //https://github.com/mzucker/noteshrink // Test pack_rgb and unpack_rgb //var im = new List<byte[]>() //{ // new byte[] { 230, 230, 226 }, // new byte[] { 242, 238, 234 } //}; //var pck = pack_rgb(im); //var upck0 = unpack_rgb(pck[0]); //var upck1 = unpack_rgb(pck[1]); //img = np.array(pil_img) var target = new Accord.Imaging.Converters.ImageToMatrix(0, 255); byte[][][] npimage; target.Convert(inBmp, out npimage); var samples = sample_pixels(npimage); var palette = get_palette(samples); var labels = apply_palette(npimage, palette); save("foo.png", labels, palette); }
List <List <byte[, ]> > BitList2Mat(List <List <Bitmap> > input) { Bitmap2matrix = new Accord.Imaging.Converters.ImageToMatrix(); List <List <byte[, ]> > output = new List <List <byte[, ]> >(); for (int i = 0; i < input.Count; i++) { List <byte[, ]> temp = new List <byte[, ]>(); for (int j = 0; j < input[i].Count; j++) { byte[,] outMat = new byte[input[i][j].Width, input[i][j].Height]; Bitmap2matrix.Convert(input[i][j], out outMat); temp.Add(outMat); } output.Add(temp); } return(output); }