/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* FUNCTION
* mlib_ImageThresh1 - thresholding
*
* SYNOPSIS
* mlib_status mlib_ImageThresh1(mlib_image *dst,
* const mlib_image *src,
* const mlib_s32 *thresh,
* const mlib_s32 *ghigh,
* const mlib_s32 *glow);
*
* ARGUMENT
* dst pointer to output image
* src pointer to input image
* thresh array of thresholds
* ghigh array of values above thresholds
* glow array of values below thresholds
*
* RESTRICTION
* The images must have the same size, and the same number
* of channels.
* The images can have 1, 2, 3, or 4 channels.
* The images can be in MLIB_BYTE, MLIB_SHORT or MLIB_INT data type.
* The type of the output image can be MLIB_BIT, or the same as the
* type of the input image.
*
* DESCRIPTION
* If the pixel band value is above the threshold for that channel,
* set the destination to the ghigh value for that channel.
* Otherwise, set the destination to the glow value for that channel.
*
* +- glow[c] src[x][y][c] <= thresh[c]
* dst[x][y][c] = |
* +- ghigh[c] src[x][y][c] > thresh[c]
*/
#include "mlib_image.h"
#include "mlib_ImageCheck.h"
#include "mlib_c_ImageThresh1.h"
/***************************************************************/
/***************************************************************/
/***************************************************************/
/***************************************************************/
for ( i = 0; i < h; i++ ) { \
for (j = 0; j < w; j ++) { \
for (k = 0; k < ch; k++) { \
} \
} \
} \
}
/***************************************************************/
#define INIT_THRESH0(n) \
/***************************************************************/
#define INIT_THRESH1(n) \
/***************************************************************/
#define INIT_THRESH2(n) \
/***************************************************************/
#define INIT_THRESH3(n) \
/***************************************************************/
/***************************************************************/
{
mlib_s32 i, j, k;
if (width < 16) {
return;
}
INIT_THRESH0(0);
for (i = 0; i < height; i++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
for (; j < width; j++) {
}
psrc_row += src_stride;
pdst_row += dst_stride;
}
}
/***************************************************************/
{
mlib_s32 i, j, k;
if (width < 16) {
return;
}
INIT_THRESH0(0);
INIT_THRESH1(1);
width <<= 1;
for (i = 0; i < height; i++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
for (; j < width; j += 2) {
}
psrc_row += src_stride;
pdst_row += dst_stride;
}
}
/***************************************************************/
{
mlib_s32 i, j, k;
if (width < 16) {
return;
}
INIT_THRESH0(0);
INIT_THRESH1(1);
INIT_THRESH2(2);
for (i = 0; i < height; i++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
for (; j < width; j += 3) {
}
psrc_row += src_stride;
pdst_row += dst_stride;
}
}
/***************************************************************/
{
mlib_s32 i, j, k;
if (width < 16) {
return;
}
INIT_THRESH0(0);
INIT_THRESH1(1);
INIT_THRESH2(2);
INIT_THRESH3(3);
width *= 4;
for (i = 0; i < height; i++) {
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
}
if (j < width) {
}
psrc_row += src_stride;
pdst_row += dst_stride;
}
}
/***************************************************************/
{
for (i = 0; i < height; i++) {
j = 0;
jbit = 0;
if (dbit_off) {
dst0 = 0;
emask = 0;
for (; j < nume; j++) {
}
jbit++;
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
jbit++;
jbit++;
}
if (width - j >= 8) {
jbit++;
j += 8;
}
if (j < width) {
dst0 = 0;
l = 7;
for (; j < width; j++) {
l--;
}
}
psrc_row += src_stride;
pdst_row += dst_stride;
}
}
/***************************************************************/
{
width *= 2;
for (i = 0; i < height; i++) {
j = 0;
jbit = 0;
if (dbit_off) {
dst0 = 0;
emask = 0;
}
if (j < nume) {
/* swap threshes */
j++;
}
jbit++;
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
jbit++;
jbit++;
}
if (width - j >= 8) {
jbit++;
j += 8;
}
if (j < width) {
dst0 = 0;
l = 7;
l -= 2;
}
if (j < width) {
l--;
}
}
psrc_row += src_stride;
pdst_row += dst_stride;
}
}
/***************************************************************/
{
if (ghigh[0] > 0)
mhigh = 0x492492;
if (ghigh[1] > 0)
mhigh |= 0x249249;
if (ghigh[2] > 0)
mhigh |= 0x924924;
if (glow[0] > 0)
mlow = 0x492492;
if (glow[1] > 0)
mlow |= 0x249249;
if (glow[2] > 0)
mlow |= 0x924924;
for (i = 0; i < height; i++) {
j = 0;
jbit = 0;
if (dbit_off) {
dst0 = 0;
emask = 0;
}
for (; j < nume; j++) {
/* swap threshes */
}
jbit++;
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
jbit++;
jbit++;
jbit++;
}
if (j < width) {
k = width - j;
dst0 = 0;
l = 31;
for (; j < width; j += 3) {
l -= 3;
}
l = (k + 7) >> 3;
k = (l << 3) - k;
emask = (0xFF << k);
if (l == 3) {
}
else if (l == 2) {
}
else {
}
}
psrc_row += src_stride;
pdst_row += dst_stride;
}
}
/***************************************************************/
{
width *= 4;
for (i = 0; i < height; i++) {
j = 0;
jbit = 0;
if (dbit_off) {
dst0 = 0;
emask = 0;
}
for (; j < nume; j++) {
/* swap threshes */
}
jbit++;
}
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
jbit++;
jbit++;
}
if (j <= width - 8) {
jbit++;
j += 8;
}
if (j < width) {
}
psrc_row += src_stride;
pdst_row += dst_stride;
}
}
/***************************************************************/