Coder Social home page Coder Social logo

philliec459 / create-thin-section-image-labels-for-semantic-segmentation-training Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 3.0 13.52 MB

This is an example of creating labeled images to be used in Keras image-segmentation training

License: MIT License

Python 99.42% HTML 0.58%
image-labels image-segmentation thin-sections petrography divam-gupta-github

create-thin-section-image-labels-for-semantic-segmentation-training's Introduction

Create-Thin-Section-Labels

Create Labels for Thin Sections for image-segmentation-keras:

This repository is meant to document the steps being employed to create a labeled Thin Section image for the image segmentation using Keras per Divam Gupta's GitHub repository.

Objective

The objective of this repository is to label different types of grains or blue dye epoxy (which represents visual porosity) observed in clastic petrographic thin sections of rock samples. The following image is an example of a typical clastic rock thin section and the histogram of the pixel values:

Image

Load Image

We read in the original Thin Section image and create a Numpy array.

TS_Im = Image.open(img)

data = np.array(TS_Im) 

Convert to Gray-Level Image

We then convert the color image to a gray-level image using the following code:

gradient = gaussian(rgb2gray(data)) 

using skimage filter gaussian (or median) filters and skimage rgb2gray.

The following is an example of the gray-level image and histogram of these data scaled 0 to 1.

Image

Partition Gray-Level Image to Create Labeled Images

We then partition the gray-level image data into different bins which will serve as our labels:

label = np.zeros(gradient.shape )

label[gradient < 0.25] = 1 #black grains 
label[gradient > 0.25] = 2 #darker grains
label[gradient > 0.4]  = 3 #blue-dye epoxy or visual porosity  
label[gradient > 0.6]  = 4 #darker grains 
label[gradient > 0.75] = 5 #bright quartz grains   

Per the advice of Divam Gupta we are scaling our label images from 0 to n_classes to create the 5 labels that represent the various segments in our Thin Section images. We use the python program "review_images_Create_Labels_n_classes.py" to create these labels scaled from 0 to n_classes. These are the type of labeled images that were used for the annotated labels for our image segmentation training data.

Image

The histogram verifies that we have 5 labels in our saved label images.

Interactive Program to Display Pixel Values of Labels

There is another python program that should be driven from the xterm command line using "python interactive_plot.py" as the command.

This program will create an interactive display of the 3.png image to display the pixel values of the labeled image. This tool can be used to confirm, optimize the label cutoffs used in segmental thresholding and ensure that these segment values are well understood.

Image

create-thin-section-image-labels-for-semantic-segmentation-training's People

Contributors

philliec459 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

create-thin-section-image-labels-for-semantic-segmentation-training's Issues

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.