|
Size: 2622
Comment:
|
Size: 2594
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 36: | Line 36: |
| 1. Edit the file in the project called "CC3D_import_image_Complex_map_cells_Parameters.py" which defines the color mapping you want. 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. 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. 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 |
| Line 43: | Line 43: |
| {{attachment:QuickModels/Image_2_cells_screenshot.png|Cell Field|width=200px}} And that's it. You can of course now manipulate the image any way you want. Or create CC3D cells based on the pixel in the field. |
{{attachment:QuickModels/Image_2_cells_screenshot.png|Cell Field|width=400px}} |
Importing an image into CC3D and creating Cells
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.
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?
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.
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