Code Monkey home page Code Monkey logo

sivkri / imagecoloranalysis Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2.11 MB

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.

Home Page: https://github.com/sivkri/Count-stomata-and-pavement-cells

License: GNU General Public License v2.0

Python 85.32% Shell 14.68%
stomata stomatal-index pavement-images pavement bash-scripts color-analysis computer-vision data-analysis image-classification image-processing

imagecoloranalysis's Introduction

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

imagecoloranalysis's People

Contributors

sivkri avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.