Skip to content

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.

License

Notifications You must be signed in to change notification settings

sivkri/ImageColorAnalysis

Repository files navigation

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/your-username/repository-name.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.

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

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published