-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c31f269
commit a69b967
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
%% Histogram-based global thresholding | ||
% Elen, A. & Dönmez, E., Histogram-based global thresholding method for | ||
% image binarization, Optik, vol. 306, pp. 1-20 (2024). | ||
% https://doi.org/10.1016/j.ijleo.2024.171814 | ||
% ------------------------------------------------------------------------- | ||
|
||
clc; | ||
clear; | ||
close all; | ||
|
||
%% Section 1: Get image. | ||
% Set full path to the image. | ||
imgFile = 'Images\Test.gif'; | ||
% Read image data. | ||
img = imread(imgFile); | ||
% Convert RGB image to grayscale, if need. | ||
if (imfinfo(imgFile).BitDepth > 8) | ||
img = rgb2gray(img); | ||
end | ||
|
||
%% Section 2: Run method. | ||
thresholdElen = ElenThreshold(img); | ||
|
||
% Binarize the image by threshold value. | ||
binImg = imbinarize(img, thresholdElen / 256.0); | ||
|
||
|
||
%% Section 3: Show result. | ||
fig = figure(); | ||
sgtitle('Elen''s Thresholding Method.'); | ||
|
||
subplot(1, 2, 1); | ||
imshow(img); | ||
title('Input Image'); | ||
|
||
subplot(1, 2, 2); | ||
imshow(binImg); | ||
title('Output Image'); | ||
|