jabcode
 All Classes Files Functions Variables Enumerations Macros
binarizer.c File Reference

Binarize the image. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "jabcode.h"

Macros

#define BLOCK_SIZE_POWER   3
 
#define BLOCK_SIZE   (1 << BLOCK_SIZE_POWER)
 
#define BLOCK_SIZE_MASK   (BLOCK_SIZE - 1)
 
#define MINIMUM_DIMENSION   (BLOCK_SIZE * 5)
 
#define CAP(val, min, max)   (val < min ? min : (val > max ? max : val))
 

Functions

jab_boolean isBiTrimodal (jab_float hist[], jab_int32 channel)
 Check bimodal/trimodal distribution. More...
 
jab_int32 getMinimumThreshold (jab_int32 hist[], jab_int32 channel)
 Get the minimal value in a histogram with bimodal distribution. More...
 
jab_bitmapbinarizerHist (jab_bitmap *bitmap, jab_int32 channel)
 Binarize a color channel of a bitmap using histogram binarization algorithm. More...
 
jab_bitmapbinarizerHard (jab_bitmap *bitmap, jab_int32 channel, jab_int32 threshold)
 Binarize a color channel of a bitmap using a given threshold. More...
 
void getBinaryBitmap (jab_bitmap *bitmap, jab_int32 channel, jab_int32 sub_width, jab_int32 sub_height, jab_byte *black_points, jab_bitmap *binary)
 Do local binarization based on the black points. More...
 
void calculateBlackPoints (jab_bitmap *bitmap, jab_int32 channel, jab_int32 sub_width, jab_int32 sub_height, jab_byte *black_points)
 Calculate the black point of each block. More...
 
void filterBinary (jab_bitmap *binary)
 Filter out noises in binary bitmap. More...
 
jab_bitmapbinarizer (jab_bitmap *bitmap, jab_int32 channel)
 Binarize a color channel of a bitmap using local binarization algorithm. More...
 

Detailed Description

Binarize the image.

libjabcode - JABCode Encoding/Decoding Library

Copyright 2016 by Fraunhofer SIT. All rights reserved. See LICENSE file for full terms of use and distribution.

Contact: Huajian Liu liu@s.nosp@m.it.f.nosp@m.raunh.nosp@m.ofer.nosp@m..de Waldemar Berchtold walde.nosp@m.mar..nosp@m.berch.nosp@m.told.nosp@m.@sit..nosp@m.frau.nosp@m.nhofe.nosp@m.r.de

Function Documentation

jab_bitmap* binarizer ( jab_bitmap bitmap,
jab_int32  channel 
)

Binarize a color channel of a bitmap using local binarization algorithm.

Parameters
bitmapthe input bitmap
channelthe color channel
Returns
binarized bitmap | NULL if failed
jab_bitmap* binarizerHard ( jab_bitmap bitmap,
jab_int32  channel,
jab_int32  threshold 
)

Binarize a color channel of a bitmap using a given threshold.

Parameters
bitmapthe input bitmap
channelthe color channel
thresholdthe threshold
Returns
binarized bitmap | NULL if failed
jab_bitmap* binarizerHist ( jab_bitmap bitmap,
jab_int32  channel 
)

Binarize a color channel of a bitmap using histogram binarization algorithm.

Parameters
bitmapthe input bitmap
channelthe color channel
Returns
binarized bitmap | NULL if failed
void calculateBlackPoints ( jab_bitmap bitmap,
jab_int32  channel,
jab_int32  sub_width,
jab_int32  sub_height,
jab_byte *  black_points 
)

Calculate the black point of each block.

Parameters
bitmapthe input bitmap
channelthe color channel
sub_widththe number of blocks in x direction
sub_heightthe number of blocks in y direction
black_pointsthe black points
void filterBinary ( jab_bitmap binary)

Filter out noises in binary bitmap.

Parameters
binarythe binarized bitmap
void getBinaryBitmap ( jab_bitmap bitmap,
jab_int32  channel,
jab_int32  sub_width,
jab_int32  sub_height,
jab_byte *  black_points,
jab_bitmap binary 
)

Do local binarization based on the black points.

Parameters
bitmapthe input bitmap
channelthe color channel
sub_widththe number of blocks in x direction
sub_heightthe number of blocks in y direction
black_pointsthe black points
binarythe binarized bitmap
jab_int32 getMinimumThreshold ( jab_int32  hist[],
jab_int32  channel 
)

Get the minimal value in a histogram with bimodal distribution.

Parameters
histthe histogram
channelthe color channel
Returns
minimum threshold | -1 if failed
jab_boolean isBiTrimodal ( jab_float  hist[],
jab_int32  channel 
)

Check bimodal/trimodal distribution.

Parameters
histthe histogram
channelthe color channel
Returns
JAB_SUCCESS | JAB_FAILURE