https://github.com/sivkri/imagecoloranalysis
ImageColorAnalysis is a repository with a Python script for color analysis in images using ImageMagick. It generates bash scripts for individual JPG images to analyze specific colors. It provides a flexible solution for extracting color information from images, applicable in various domains such as image classification and data analysis.
https://github.com/sivkri/imagecoloranalysis
bash-scripts color-analysis computer-vision data-analysis image-classification image-processing imagemagick pavement pavement-images python-scripting stomata stomatal-index
Last synced: 9 months ago
JSON representation
ImageColorAnalysis is a repository with a Python script for color analysis in images using ImageMagick. It generates bash scripts for individual JPG images to analyze specific colors. It provides a flexible solution for extracting color information from images, applicable in various domains such as image classification and data analysis.
- Host: GitHub
- URL: https://github.com/sivkri/imagecoloranalysis
- Owner: sivkri
- License: gpl-2.0
- Created: 2021-10-01T08:02:31.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-12T12:45:49.000Z (11 months ago)
- Last Synced: 2025-02-12T13:56:13.895Z (11 months ago)
- Topics: bash-scripts, color-analysis, computer-vision, data-analysis, image-classification, image-processing, imagemagick, pavement, pavement-images, python-scripting, stomata, stomatal-index
- Language: Python
- Homepage: https://github.com/sivkri/Count-stomata-and-pavement-cells
- Size: 2.07 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Image Processing Repository
This repository contains a Python script for image processing tasks. The script processes a set of JPG images and performs color analysis on them using ImageMagick.
## Prerequisites
Before running the script, ensure that the following dependencies are installed:
- Python
- ImageMagick
## Installation
To use this script, follow these steps:
1. Clone the repository:
```
git clone https://github.com/sivkri/ImageColorAnalysis.git
```
2. Navigate to the cloned repository:
```
cd repository-name
```
3. Install the required dependencies:
```
pip install -r requirements.txt
```
## Usage
1. Make sure the required images are present in the repository directory.
2. Open the Python script `script.py` and ensure that the correct image filenames are specified in the `dict_samples` dictionary.
3. Run the script:
```
python script.py
```
This will generate a set of bash scripts in the `scripts` directory, each corresponding to an individual image.
4. Optionally, you can check whether the required images were taken into consideration by uncommenting the line `#print dict_samples` in the script.
5. Once the script has finished running, you can execute the generated bash scripts individually to perform color analysis on each image.
## Additional Notes
- The script uses ImageMagick's `convert` command to process the images. Make sure that ImageMagick is properly installed and accessible from the command line.
- The color analysis is performed for two colors, "red" and "yellow". You can modify the colors or add more colors as per your requirements by editing the bash script template in the `text` variable.
- The bash scripts generated by the script are saved in the `scripts` directory with the naming convention `result1.sh`, `result2.sh`, and so on, corresponding to each image.
- The script assumes that the images are in JPG format and are located in the same directory as the script. If your images are in a different format or location, make sure to modify the script accordingly.
- Feel free to customize the script to suit your specific image processing needs.
## License
This project is licensed under the [MIT License](LICENSE).
# Count Stomata and pavement cells
A step by step guide to count stomata using Linux (Machine Learning)
**Disclaimer** : Every file is given separately to cross check the results, before proceeding to the next step. The below codes are tested on Ubuntu 18.04.5 LTS using bash, Python2.7 or ImageMagick.
A. **_Installation_**
Install **conda** as instructed by https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html.
Install **ImageMagick** as instructed by https://anaconda.org/conda-forge/imagemagick. By default, it will install all the dependencies along with the relavant libraries.
Install **python** using conda and then use pip, to install module/packages required - _sys, os, glob_.
Either *png or jpg* format are recommended. Since the image captured by microscope must be edited/measured using Microsoft paint 2D, if you save the file in another format like TIF, then you can change to above mentioned preferred format.
B. **_Drawing a sticker/dots over the leaf_**
location = /home/username/Documents
Steps to add dots/stickers to the image
1. Open the file in the PAINT 3D and start painting as mentioned below.
2. Select option -> 2D Shapes -> round shape -> Both line type and fill should be red for _stomata_ -> similarly do for the _pavement cells_ using yellow color -> save image in a new folder.
Example files are attached in the rar format
Save image file with the ending "dots.png" or "dots.jpg" (**file Extension** and **name ending** is much more important), since the next python file will look for this and start creating bash files. Warning: You should not work with original file received taken from microscope.
C. **_Create bash files for every images_**
1. Run command to create a new_folder/directory
mkdir scripts
Saved location = /home/username/Documents/scripts
2. Run the below command to create bash files separately for all the images
python2.7 create_bash_files.py
location = Saved location = /home/username/Documents
If you want to redirect all the output to a text file then use "python2.7 create_bash_files.py >created_text.txt".
Result file should be in the file -> /home/username/Documents/created_text.txt
D. **_Counting the cells_**
Run the command "python2.7 count_stomata.sh >final_count.txt".
Result file should be in the file -> /home/username/Documents/final_count.txt
some of the useful links
https://stackoverflow.com/questions/44439555/count-colored-dots-in-image#comment75876873_44439555
https://stackoverflow.com/questions/25907351/how-to-read-specific-dots-on-an-image-then-export-values-to-html-automatically