Skip to main content

A package to count scales on reptiles.

Project description

ScaleCounter

ScaleCounter allows users to count scales easily. The script has methods that can estimate the scales in a large area where scales are overall uniform but in some places difficult to count by hand. It can also count the total scales in smaller good quality images. There are two different methods that can handle for these cases. This should save time and tedium in laboratory settings, providing even results. The main code is in ScaleCounter_Public_Functions.py

Image Requirements

Works best for:

  • scales and colonies that are not overlapping and instead are distinct
  • images taken without flash
  • scales and colonies that contrast their background/medium and are paler than the background
  • scales with overall uniform color
  • skin/background that has uniform color in image

*It is okay if there is uneven lighting in someplaces (as long as no flash)

Other Requirements

  • numpy
  • matplotlib
  • opencv2
  • IPython.display
  • pandas
  • image_slicer
  • statistics
  • datascience

Method Frameworks

count_scales():

count_scales(img_name, check_invert='auto', noise_thresh=1/7)

Ideal for smaller images that have very clearly defined scales. Image should be good quality and mostly countable by hand.

  1. Performs Otsu threshold and uses results to determine blocksize and iterations.
  2. Performs adaptive thresholding using selected blocksize and iterations. Removes noise.
  3. Calculates a score for the result based on scale size variation and uniformity of distribution. The lower the score, the better.
  4. If the score is too high, repeat steps 1-3 on inverted image and see if the score for the inverted image is lower. Keep the one with lower score.
Screenshot 2021-04-19 at 4 48 56 PM

count_scales_directory():

count_scales_directory(dirname)

Runs count_scales on each image in the directory.

split_count_select: Green boxes indicate steps unique to split_count_select()

split_count_select(img_path, num_subimages=0, num_to_keep=0)

Ideal for images that are large with scales/spots that are unclear in some regions.

For each subimage:

  1. Runs count_scales on each subimage.
  2. Finally, choose the subimages with the best scores.
  3. Estimates total count using the selected subimages.
Screenshot 2021-04-19 at 4 49 13 PM

display_results():

display_results(results_list, output_name="ScaleCounter_results_display", best_indices_lst=None, estimated_total=None)

Displays pdf showing labeled and counted images.


Examples (using count_scales):

Screenshot 2021-04-16 at 12 48 31 AM

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ScaleCounter-0.0.5.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ScaleCounter-0.0.5-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file ScaleCounter-0.0.5.tar.gz.

File metadata

  • Download URL: ScaleCounter-0.0.5.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

File hashes

Hashes for ScaleCounter-0.0.5.tar.gz
Algorithm Hash digest
SHA256 948b61b8857531e05661465bfb06eb95504d14b99654b207124e7d46e9f27367
MD5 b7cf1c1aca6ef979983b6f960a2ac721
BLAKE2b-256 de9608586393cc6188c155fcff3bc3ee4036a8c02f801fe773c6805c2b55a129

See more details on using hashes here.

File details

Details for the file ScaleCounter-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: ScaleCounter-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

File hashes

Hashes for ScaleCounter-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6455aa3b2bba8dc831bf5f358abaa1892b704903b7ef1202d1417ece8b91ea53
MD5 b1c3f660e66e052c7bbbee70196c5b65
BLAKE2b-256 522c564137f00ffe8eef3c8e581dfcdb3f2701e689efedad05a03efba4f2c1d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page