Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added demos: Histogram Equalization and RGB to Grayscale conversion #133

Merged
merged 6 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/examples/color_channels/rgb_grayscale.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ---
# title: RGB to GrayScale
# cover: assets/rgb_grayscale.png
# ---

# This example illustrates RGB to Grayscale Conversion


using Images, TestImages
mgautam98 marked this conversation as resolved.
Show resolved Hide resolved

rgb_image = testimage("lighthouse")

# I = Gray.(RGB) converts an RGB image to Grayscale.
mgautam98 marked this conversation as resolved.
Show resolved Hide resolved

gray_image = Gray.(rgb_image)
hcat(rgb_image, gray_image)
mgautam98 marked this conversation as resolved.
Show resolved Hide resolved

# Gray scale conversion form RGB follows a weighted sum of all channels, the coffecients are computed according to
# [Rec. ITU-R BT.601-7](https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf) rounding off to 3 decimal places
# `0.299 * R + 0.587 * G + 0.114 * B`

save("assets/rgb_grayscale.png", gray_image) #src
31 changes: 31 additions & 0 deletions docs/examples/spatial_transformation/histogram_equalization.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ---
# title: Histogram equalisation
# cover: assets/histogram_equalization.png
# ---

# This demo issustrates the use of [Histogram equalization](https://juliaimages.org/ImageContrastAdjustment.jl/stable/reference/#Equalization-1), [gamma correction matching](https://juliaimages.org/ImageContrastAdjustment.jl/stable/reference/#Matching-1)
# and [Contrast Limited Adaptive Histogram Equalization](https://juliaimages.org/ImageContrastAdjustment.jl/stable/reference/#AdaptiveEqualization-1)

# Histogram equalisation is used to imporve the contrast in an
# single-channel grayscale image. It distributes the intensity of the image
# in a uniform manner. The natural justification for uniformity
# is that the image has better contrast if the intensity levels of an image span
# a wide range on the intensity scale. The transformation is based on mapping of
# cumulative histogram

using ImageContrastAdjustment, TestImages

img = testimage("moonsurface")

# Now we will apply Histogram equalisation, gamma correction and Adaptive histogram equalisation
# method to enhance contrast of the image

hist_equal = adjust_histogram(img, Equalization(nbins = 256))
gamma_correction = adjust_histogram(img, GammaCorrection(gamma = 2))
hist_adapt = adjust_histogram(img, AdaptiveEqualization(nbins = 256, rblocks = 4, cblocks = 4, clip = 0.2))

hcat(img, hist_equal, gamma_correction, hist_adapt)
mgautam98 marked this conversation as resolved.
Show resolved Hide resolved

# --- save covers --- #src
using Images #src
mgautam98 marked this conversation as resolved.
Show resolved Hide resolved
save("assets/histogram_equalization.png", hist_equal) #src