|
Size: 2599
Comment:
|
Size: 3766
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 3: | Line 3: |
| If you have created a cell layout suing a drawing tool (like p!PoerPoint, or Paint or ....) and you would like to import that image into CC3D and create a cell field based on the image, here is how you do it. | If you have created a cell layout suing a drawing tool (like !PowerPoint, or Paint or ....) and you would like to import that image into CC3D and create a cell field based on the image, here is how you do it. |
| Line 5: | Line 5: |
| So you have created an image in a drawing program (like !PowerPoint), or perhaps you have a photo or perhaps even a microscope image and you want to import it into CC3D? | The goal of this CC3D project is to; 1. read a bmp (or jpg, png, ...) image showing a cell layout (probably create in a simple drawing program) 2. convert the image into a set of cells in CC3D 3. save the resulting CC3D layout as a piff file Need to install PIL Note that if cell boundary display is turned on in Player then you may get the entire field colored by the boarder color after all pixels in the image are made into individual cells. Tested with formats: 1. gif: NO 2. jpg: OK 3. png: OK 4. bmp: OK This version is for importing a cell field drawing and maping to CC3D cells. The parameters, file names, colors etc. are in a "CC3D_import_image_Complex_map_cells_parameters.py" file |
| Line 22: | Line 42: |
| 1. The drawing should NOT be anti-aliased (aliasing fuzzy's up the borders). 1. Use white for medium (255,255,255) 1. Use Black for cell boundaries (0,0,0) 1. Simple colors are a bit easier (though you can use any color), so start with red (255,0,0), green (0,255,0), blue (0,0,255),... 1. All cells of the same type should have the same color. 1. The image should be about the same pixel dimension that it will be used in CC3D. This code can not interpolate or extrapolate to fit the image into a CC3D window of different dimensions. It could put a smaller image into a larger CC3D window though. |
|
| Line 38: | Line 65: |
| 1. define the path and filename to your image 1. Define the size of the CC3D layout (which normally matches the dimensions of your image) 1. Define the color ranges that map to each cell type |
1. define the path and filename to your image 1. Define the size of the CC3D layout (which normally matches the dimensions of your image) 1. Define the color ranges that map to each cell type |
Importing an image into CC3D and creating Cells
If you have created a cell layout suing a drawing tool (like PowerPoint, or Paint or ....) and you would like to import that image into CC3D and create a cell field based on the image, here is how you do it.
The goal of this CC3D project is to;
- read a bmp (or jpg, png, ...) image showing a cell layout (probably create in a simple drawing program)
- convert the image into a set of cells in CC3D
- save the resulting CC3D layout as a piff file
Need to install PIL
Note that if cell boundary display is turned on in Player then you may get the entire field colored by the boarder color after all pixels in the image are made into individual cells.
Tested with formats: 1. gif: NO 2. jpg: OK 3. png: OK 4. bmp: OK
This version is for importing a cell field drawing and maping to CC3D cells. The parameters, file names, colors etc. are in a "CC3D_import_image_Complex_map_cells_parameters.py" file
Here is how you do it, it has a couple steps, but isn't too difficult. (This is written for CompuCell3D 4.x and Python 3.x)
1. By default, the Python installed with CC3D does not include the Python Image Library (PIL) so you will have to install it. To do that:
Open a command window and browse to the Scripts folder in the Python directory installed with CC3D. On a windows machine it will be in the directory:
- C:\CompuCell3D-py3-64bit\python36\Scripts\
Run pip, the standard python installer, to install the Image library
- pip.exe install Image
- Hopefully every thing goes OK and you now have PIL installed, which includes the Image package.
2. Create an image of your cell field using the drawing tool of you choice.
- The drawing should NOT be anti-aliased (aliasing fuzzy's up the borders).
- Use white for medium (255,255,255)
- Use Black for cell boundaries (0,0,0)
- Simple colors are a bit easier (though you can use any color), so start with red (255,0,0), green (0,255,0), blue (0,0,255),...
- All cells of the same type should have the same color.
- The image should be about the same pixel dimension that it will be used in CC3D. This code can not interpolate or extrapolate to fit the image into a CC3D window of different dimensions. It could put a smaller image into a larger CC3D window though.
3. Save the image in a bit mapped format that the PIL-Image library supports:
- jpg, jpeg
- png
- bmp
- not that GIF does not work.
- If you have a different image format you will need to convert it to one of the formats listed above.
4. Finally, you need a CC3D code to read the image and convert it into a set of cells in CC3D. Here is a CC3D project that you can use to do this.
- It is best if you know how big the image is and setup CC3D so that the simulation window is at least that big. Many image viewing programs will tell you the size of the image in pixels.
Download and unzip this zip file
- In the project folder that you just unzipped, place the image you want to use in the "Simulation" folder.
1. Edit the file in the project called "CC3D_import_image_Complex_map_cells_Parameters.py" which defines the color mapping you want.
- define the path and filename to your image
- Define the size of the CC3D layout (which normally matches the dimensions of your image)
- Define the color ranges that map to each cell type
- Run the CC3D project, which outputs a .piff file based on your image.
CompuCell3D