algorithmic modeling for Rhino
I have a problem, I would like to transform an image (color or monochrome) in a mesh (with UV value are adjustable to the size of the image) and associate with each color a letter or number (example: black (or RGB value) = A1, green = BB etc ...) and get to the end of a text file with Num. columns = Vmesh and Num. rows = Umesh.
1) there is a problem at the color transition (personally it's possible to even approximate the boundary color (like pixelate effect) to one of two adjacent colors.
2) text file.
I do not know if I was clear but one example for instance could be the one of the images converted to ASCII codes.
Thank you in advance!
Tags:
Maybe this can be a start...
""""""""""""""""""""""""""""
private void RunScript(string path, List<Color> colors, List<string> texts, ref object A)
{
List<string> text = new List<string>();
Bitmap myBitmap = new Bitmap(path);
//A = colors[0];
for (int x = 0; x < (myBitmap.Height); x++) {
for (int y = 0; y < (myBitmap.Width); y++) {
for (int c = 0; c < (colors.Count); c++) {
if (colors[c] == myBitmap.GetPixel(x, y)) {
text.Add(texts[c]);
}
}
}
}
A = text;
}
""""""""""""""""""""""""""""
(use right-click in inputs to change name, Access method and type hint)
Place attached "test.bmp" to a "C:\test\" folder
I think the pattern is vertically flipped because bitmaps are managed with Y at the opposite of normal Cartesian CAD (what? :D I don't know...)
I haven't found how to output to a file...
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by