/*
* 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_ImageColorTrue2Index - convert a true color image to an indexed
* color image
*
* SYNOPSIS
* mlib_status mlib_ImageColorTrue2Index(mlib_image *dst,
* const mlib_image *src,
* const void *colormap)
*
* ARGUMENTS
* colormap Internal data structure for inverse color mapping.
* dst Pointer to destination image.
* src Pointer to source image.
*
* DESCRIPTION
* Convert a true color image to a pseudo color image with the method
* of finding the nearest matched lut entry for each pixel.
*
* The src can be an MLIB_BYTE or MLIB_SHORT image with 3 or 4 channels.
* The dst must be a 1-channel MLIB_BYTE or MLIB_SHORT image.
*
* The lut might have either 3 or 4 channels. The type of the lut can be
* one of the following:
* MLIB_BYTE in, MLIB_BYTE out (i.e., BYTE-to-BYTE)
* MLIB_BYTE in, MLIB_SHORT out (i.e., BYTE-to-SHORT)
* MLIB_SHORT in, MLIB_SHORT out (i.e., SHORT-to-SHORT)
* MLIB_SHORT in, MLIB_BYTE out (i.e., SHORT-to-BYTE)
*
* The src image and the lut must have same number of channels.
*/
#include "mlib_image.h"
#include "mlib_ImageColormap.h"
#include "mlib_ImageCheck.h"
/***************************************************************/
/*#define USE_VIS_CODE*/
#ifdef USE_VIS_CODE
#include "vis_proto.h"
#endif
/***************************************************************/
/***************************************************************/
for( y = 0; y < height; y++ ) \
{ \
\
}
/***************************************************************/
{ \
mlib_s32 j; \
\
\
switch( bits ) \
{ \
case 1: \
case 2: \
{ \
\
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
case 3: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
case 4: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
case 5: \
case 6: \
case 7: \
{ \
\
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
case 8: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
} \
}
/***************************************************************/
{ \
mlib_s32 j; \
\
\
switch( bits ) \
{ \
case 1: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 2: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 3: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 4: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 5: \
case 6: \
{ \
\
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 7: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 8: /* will never be called */ \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
} \
}
/***************************************************************/
{ \
mlib_s32 j; \
\
\
switch( bits ) \
{ \
case 1: \
case 2: \
case 3: \
case 4: \
case 5: \
{ \
\
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
case 6: \
case 7: \
{ \
\
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
case 8: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
case 9: \
case 10: \
{ \
\
for( j = 0; j < length; j++ ) \
{ \
\
} \
break; \
} \
/* Other cases may not be considered as the table size will be more \
than 2^32 */ \
} \
}
/***************************************************************/
{ \
mlib_s32 j; \
\
\
switch( bits ) \
{ \
case 1: \
case 2: \
case 3: \
{ \
\
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 4: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 5: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 6: \
case 7: \
{ \
\
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
case 8: \
{ \
for( j = 0; j < length; j++ ) \
{ \
\
c0 += 4; \
c1 += 4; \
c2 += 4; \
c3 += 4; \
} \
break; \
} \
/* Other cases may not be considered as the table size will be more \
than 2^32 */ \
} \
}
/***************************************************************/
{ \
continue_up = 1; \
}
/***************************************************************/
{ \
{ \
{ \
{ \
/* Check only a part of quadrant */ \
\
check_corner += 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Only a part of quadrant needs checking */ \
distance = \
distance, &found_color, c, p, \
} \
else /* Check whole quadrant */ \
{ \
\
check_corner += 2; \
continue_up = 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it */ \
} \
} \
else /* Cell is on the edge of the space */ \
{ \
COLOR_MAX ) \
{ \
/* Check only a part of quadrant */ \
\
check_corner += 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Only a part of quadrant needs checking */ \
distance = \
distance, &found_color, c, p, \
} \
else /* Check whole quadrant */ \
{ \
\
check_corner += 2; \
continue_up = 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it */ \
} \
} \
} \
}
/***************************************************************/
{ \
{ \
{ \
{ \
/* Check only a part of quadrant */ \
\
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Only a part of quadrant needs checking */ \
distance = \
distance, &found_color, c, p, \
} \
else /* Check whole quadrant */ \
{ \
\
continue_up = 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it */ \
} \
} \
else /* Cell is on the edge of the space */ \
{ \
COLOR_MAX ) \
{ \
/* Check only a part of quadrant */ \
\
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Only a part of quadrant needs checking */ \
distance = \
distance, &found_color, c, p, \
} \
else /* Check whole quadrant */ \
{ \
\
continue_up = 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it */ \
} \
} \
} \
}
/***************************************************************/
{ \
continue_up = 1; \
}
/***************************************************************/
{ \
if( distance > \
{ \
{ \
( c[ POSITION ] + current_size - \
{ \
\
check_corner += 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Only a part of quadrant needs checking */ \
distance = \
distance, &found_color, c, p, \
} \
else /* Check whole quadrant */ \
{ \
\
check_corner += 2; \
continue_up = 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it */ \
} \
} \
else \
{ \
{ \
\
check_corner += 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Only a part of quadrant needs checking */ \
distance = \
distance, &found_color, c, p, \
} \
else \
{ \
\
check_corner += 2; \
continue_up = 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it */ \
} \
} \
} \
}
/***************************************************************/
{ \
if( distance > \
{ \
{ \
( c[ POSITION ] + current_size - \
{ \
\
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Only a part of quadrant needs checking */ \
distance = \
distance, &found_color, c, p, \
} \
else /* Check whole quadrant */ \
{ \
\
continue_up = 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it */ \
} \
} \
else \
{ \
{ \
\
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Only a part of quadrant needs checking */ \
distance = \
distance, &found_color, c, p, \
} \
else \
{ \
\
continue_up = 1; \
{ \
/* Here is another color cell. \
Check the distance */ \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it */ \
} \
} \
} \
}
/***************************************************************/
{ \
{ \
/* Here is another color cell. Check the distance */ \
p[ 0 ][ new_found_color ], c[ 1 ], \
p[ 2 ][ new_found_color ], 0 ); \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it all */ \
c[ 0 ], c[ 1 ], c[ 2 ], p ); \
/* Else there is just an empty cell */ \
}
/***************************************************************/
{ \
{ \
/* Here is another color cell. Check the distance */ \
\
\
c[ 1 ], palc1, \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it all */ \
c[ 0 ], c[ 1 ], c[ 2 ], p ); \
/* Else there is just an empty cell */ \
}
/***************************************************************/
{ \
mlib_u32 c[ 3 ]; \
mlib_s32 j; \
\
p[ 0 ] = s->lut[ 0 ]; \
\
for( j = 0; j < length; j++ ) \
{ \
mlib_s32 we_found_it = 0; \
/* Stack pointer pointers to the first free element of stack. */ \
/* The node we are in is in the `node' */ \
struct \
{ \
struct lut_node_3 *node; \
mlib_s32 q; \
mlib_s32 stack_pointer = 0; \
\
c[ 0 ] = *channels[ 0 ] - SUBTRACTION; \
\
do \
{ \
mlib_s32 q; \
\
q = ( ( c[ 0 ] >> pass ) & 1 ) | \
\
position[ 0 ] |= c[ 0 ] & current_size; \
\
{ \
/* \
Here is a cell with one color. We need to be sure it's \
the one that is the closest to our color \
*/ \
\
\
\
{ \
/* Oh, here it is :) */ \
we_found_it = 1; \
} \
else \
{ \
/* First index is the channel, second is the number of the \
side */ \
\
found_color = palindex; \
\
do \
{ \
\
/* \
Neibours are enumerated in a cicle: \
0 - between quadrants 0 and 1, \
1 - between quadrants 1 and 2 and \
2 - between quadrants 2 and 0 \
*/ \
\
/* \
Others are three two neibour quadrants \
\
Side number is [ <number of the coordinate >][ <the bit \
in the quadrant number of the corner, corresponding to \
this coordinate> ], e.g. 2 is 0..010b, so the sides it has \
near are: \
[ 0 (coordinate number) ][ 0 (bit 0 in the number) ] \
[ 1 (coordinate number) ][ 1 (bit 1 in the number) ] \
\
Now we can look in the three nearest quadrants. Do \
we really need it ? Check it. \
*/ \
\
check_neibours[ 2 ] = 0; \
continue_up = 0; \
\
if( q & 1 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
SUBTRACTION, SHIFT ); \
} \
\
if( q & 2 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
SUBTRACTION, SHIFT ); \
} \
\
if( q & 4 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
SUBTRACTION, SHIFT ); \
} \
\
if( check_neibours[ 0 ] >= 2 ) \
{ \
} \
\
{ \
} \
\
{ \
} \
\
if( check_corner >= 3 ) \
{ \
} \
\
if( q & 1 ) \
{ \
} \
else \
{ \
BINARY_TREE_SEARCH_LEFT( 0, SHIFT ); \
} \
\
if( q & 2 ) \
{ \
} \
else \
{ \
} \
\
if( q & 4 ) \
{ \
} \
else \
{ \
} \
\
position[ 0 ] &= ~( c[ 0 ] & current_size ); \
\
current_size <<= 1; \
\
pass++; \
\
stack_pointer--; \
q = stack[ stack_pointer ].q; \
} while( continue_up ); \
\
\
we_found_it = 1; \
} \
} \
{ \
/* Descend one level */ \
stack[ stack_pointer++ ].q = q; \
} \
else \
{ \
/* Found the empty quadrant. Look around */ \
\
/* \
As we had come to this level, it is warranted that there \
are other points on this level near the empty quadrant \
*/ \
do \
{ \
\
check_neibours[ 2 ] = 0; \
continue_up = 0; \
\
if( q & 1 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
SUBTRACTION, SHIFT ); \
} \
\
if( q & 2 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
SUBTRACTION, SHIFT ); \
} \
\
if( q & 4 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
SUBTRACTION, SHIFT ); \
} \
\
if( check_neibours[ 0 ] >= 2 ) \
{ \
} \
\
{ \
} \
\
{ \
} \
\
if( check_corner >= 3 ) \
{ \
} \
\
if( q & 1 ) \
{ \
} \
else \
{ \
BINARY_TREE_SEARCH_LEFT( 0, SHIFT ); \
} \
\
if( q & 2 ) \
{ \
} \
else \
{ \
} \
\
if( q & 4 ) \
{ \
} \
else \
{ \
} \
\
position[ 0 ] &= ~( c[ 0 ] & current_size ); \
\
current_size <<= 1; \
\
pass++; \
\
stack_pointer--; \
q = stack[ stack_pointer ].q; \
} while( continue_up ); \
\
we_found_it = 1; \
} \
\
pass--; \
\
} while( !we_found_it ); \
\
} \
}
/***************************************************************/
{ \
{ \
/* Here is another color cell. Check the distance */ \
p[ 0 ][ new_found_color ], c[ 1 ], \
p[ 3 ][ new_found_color ], 0 ); \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it all */ \
c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
/* Else there is just an empty cell */ \
}
/***************************************************************/
{ \
{ \
/* Here is another color cell. Check the distance */ \
\
\
c[ 1 ], palc1, \
c[ 2 ], palc2, \
\
if( newdistance < distance ) \
{ \
distance = newdistance; \
} \
} \
/* Here is a full node. Just explore it all */ \
c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \
/* Else there is just an empty cell */ \
}
/***************************************************************/
{ \
mlib_u32 c[ 4 ]; \
mlib_s32 j; \
\
p[ 0 ] = s->lut[ 0 ]; \
\
for( j = 0; j < length; j++ ) \
{ \
mlib_s32 we_found_it = 0; \
/* Stack pointer pointers to the first free element of stack. */ \
/* The node we are in is in the `node' */ \
struct \
{ \
struct lut_node_4 *node; \
mlib_s32 q; \
mlib_s32 stack_pointer = 0; \
\
c[ 0 ] = *channels[ 0 ] - SUBTRACTION; \
\
do \
{ \
mlib_s32 q; \
\
q = ( ( c[ 0 ] >> pass ) & 1 ) | \
\
position[ 0 ] |= c[ 0 ] & current_size; \
\
{ \
/* \
Here is a cell with one color. We need to be sure it's \
the one that is the closest to our color \
*/ \
\
\
\
{ \
/* Oh, here it is :) */ \
we_found_it = 1; \
} \
else \
{ \
/* First index is the channel, second is the number of the \
side */ \
\
found_color = palindex; \
\
do \
{ \
\
/* \
Check neibours: quadrants that are different by 2 bits \
from the quadrant, that we are in: \
3 - 0 \
5 - 1 \
6 - 2 \
9 - 3 \
10 - 4 \
12 - 5 \
Far quadrants: different by 3 bits: \
7 - 0 \
11 - 1 \
13 - 2 \
14 - 3 \
*/ \
\
continue_up = 0; \
\
if( q & 1 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
} \
\
if( q & 2 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
} \
\
if( q & 4 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
} \
\
if( q & 8 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
} \
\
check_far_neibours[ 0 ] = check_neibours[ 0 ] + \
\
check_corner = check_far_neibours[ 0 ] + \
check_far_neibours[ 1 ] + \
check_far_neibours[ 2 ] + \
check_far_neibours[ 3 ]; \
\
if( check_neibours[ 0 ] >= 2 ) \
{ \
} \
\
{ \
} \
\
{ \
} \
\
{ \
} \
\
{ \
} \
\
{ \
} \
\
if( check_far_neibours[ 0 ] >= 3 ) \
{ \
} \
\
{ \
} \
\
{ \
} \
\
{ \
} \
\
if( check_corner >= 4 ) \
{ \
} \
\
if( q & 1 ) \
{ \
} \
else \
{ \
BINARY_TREE_SEARCH_LEFT( 0, SHIFT ); \
} \
\
if( q & 2 ) \
{ \
} \
else \
{ \
} \
\
if( q & 4 ) \
{ \
} \
else \
{ \
} \
\
if( q & 8 ) \
{ \
} \
else \
{ \
} \
\
position[ 0 ] &= ~( c[ 0 ] & current_size ); \
\
current_size <<= 1; \
\
pass++; \
\
stack_pointer--; \
q = stack[ stack_pointer ].q; \
} while( continue_up ); \
\
we_found_it = 1; \
} \
} \
{ \
/* Descend one level */ \
stack[ stack_pointer++ ].q = q; \
} \
else \
{ \
/* Found the empty quadrant. Look around */ \
\
/* \
As we had come to this level, it is warranted that there \
are other points on this level near the empty quadrant \
*/ \
do \
{ \
\
/* \
Check neibours: quadrants that are different by 2 bits \
from the quadrant, that we are in: \
3 - 0 \
5 - 1 \
6 - 2 \
9 - 3 \
10 - 4 \
12 - 5 \
Far quadrants: different by 3 bits: \
7 - 0 \
11 - 1 \
13 - 2 \
14 - 3 \
*/ \
\
continue_up = 0; \
\
if( q & 1 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
} \
\
if( q & 2 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
} \
\
if( q & 4 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
} \
\
if( q & 8 ) \
{ \
SUBTRACTION, SHIFT ); \
} \
else \
{ \
} \
\
check_far_neibours[ 0 ] = check_neibours[ 0 ] + \
\
check_corner = check_far_neibours[ 0 ] + \
check_far_neibours[ 1 ] + \
check_far_neibours[ 2 ] + \
check_far_neibours[ 3 ]; \
\
if( check_neibours[ 0 ] >= 2 ) \
{ \
} \
\
{ \
} \
\
{ \
} \
\
{ \
} \
\
{ \
} \
\
{ \
} \
\
if( check_far_neibours[ 0 ] >= 3 ) \
{ \
} \
\
{ \
} \
\
{ \
} \
\
{ \
} \
\
if( check_corner >= 4 ) \
{ \
} \
\
if( q & 1 ) \
{ \
} \
else \
{ \
BINARY_TREE_SEARCH_LEFT( 0, SHIFT ); \
} \
\
if( q & 2 ) \
{ \
} \
else \
{ \
} \
\
if( q & 4 ) \
{ \
} \
else \
{ \
} \
\
if( q & 8 ) \
{ \
} \
else \
{ \
} \
\
position[ 0 ] &= ~( c[ 0 ] & current_size ); \
\
current_size <<= 1; \
\
pass++; \
\
stack_pointer--; \
q = stack[ stack_pointer ].q; \
} while( continue_up ); \
\
we_found_it = 1; \
} \
\
pass--; \
\
} while( !we_found_it ); \
\
channels[ 0 ] += 4; \
} \
}
/***************************************************************/
\
for ( i = 0; i < length; i++ ) { \
min_dist = MLIB_S32_MAX; \
k_min = 1; \
\
for ( k = 1; k <= entries; k++ ) { \
} \
\
}
/***************************************************************/
#define FIND_NEAREST_U8_4_C \
\
for ( i = 0; i < length; i++ ) { \
min_dist = MLIB_S32_MAX; \
k_min = 1; \
\
for ( k = 1; k <= entries; k++ ) { \
} \
\
}
/***************************************************************/
/***************************************************************/
/***************************************************************/
#define FIND_NEAREST_U8_3 \
{ \
\
gsr[0] = vis_read_gsr(); \
{ \
src += 6; \
for( k = 1; k <= entries; k++ ) \
{ \
dres = vis_freg_pair( \
} \
} \
if( i < length ) \
{ \
for( k = 0; k < entries; k++ ) \
{ \
} \
} \
vis_write_gsr(gsr[0]); \
}
/***************************************************************/
#define FIND_NEAREST_U8_3_IN4 \
{ \
\
gsr[0] = vis_read_gsr(); \
{ \
dpsrc++; \
for( k = 1; k <= entries; k++ ) \
{ \
dres = vis_freg_pair( \
} \
} \
if( i < length ) \
{ \
for( k = 0; k < entries; k++ ) \
{ \
} \
} \
vis_write_gsr(gsr[0]); \
}
/***************************************************************/
#define FIND_NEAREST_U8_4 \
{ \
\
gsr[0] = vis_read_gsr(); \
{ \
dpsrc++; \
for( k = 1; k <= entries; k++ ) \
{ \
dres = vis_freg_pair( \
} \
} \
if( i < length ) \
{ \
for( k = 0; k < entries; k++ ) \
{ \
} \
} \
vis_write_gsr(gsr[0]); \
}
/***************************************************************/
\
for( i = 0; i < length; i++ ) \
{ \
min_dist = MLIB_S32_MAX; \
k_min = 1; \
for( k = 1; k <= entries; k++ ) \
{ \
} \
}
/***************************************************************/
#define FIND_NEAREST_S16_4 \
\
for( i = 0; i < length; i++ ) \
{ \
min_dist = MLIB_S32_MAX; \
k_min = 1; \
for( k = 1; k <= entries; k++ ) \
{ \
} \
}
/***************************************************************/
const mlib_image *src,
const void *colormap)
{
if (!colormap)
return MLIB_NULLPOINTER;
return MLIB_FAILURE;
return MLIB_FAILURE;
switch (stype) {
case MLIB_BYTE:
{
switch (dtype) {
case MLIB_BYTE:
{
switch (channels) {
case 3:
{
return MLIB_SUCCESS;
}
case 4:
{
return MLIB_SUCCESS;
}
default:
return MLIB_FAILURE;
}
}
case MLIB_SHORT:
{
dstride /= 2;
switch (channels) {
case 3:
{
return MLIB_SUCCESS;
}
case 4:
{
return MLIB_SUCCESS;
}
default:
return MLIB_FAILURE;
}
}
default:
/* Unsupported type of destination image */
return MLIB_FAILURE;
}
}
case MLIB_SHORT:
{
sstride /= 2;
switch (dtype) {
case MLIB_BYTE:
{
switch (channels) {
case 3:
{
return MLIB_SUCCESS;
}
case 4:
{
return MLIB_SUCCESS;
}
default:
return MLIB_FAILURE;
}
}
case MLIB_SHORT:
{
dstride /= 2;
switch (channels) {
case 3:
{
return MLIB_SUCCESS;
}
case 4:
{
return MLIB_SUCCESS;
}
default:
return MLIB_FAILURE;
}
}
default:
/* Unsupported type of destination image */
return MLIB_FAILURE;
}
}
default:
return MLIB_FAILURE;
}
}
/***************************************************************/
{
mlib_s32 i;
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
}
return distance;
}
/***************************************************************/
const mlib_u32 *c,
{
mlib_s32 i;
{0, 2, 4, 6},
{0, 1, 4, 5},
{0, 1, 2, 3}
};
/* Search only quadrant's half untill it is necessary to check the
whole quadrant */
if (distance < (position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) { /* Search half of quadrant */
for (i = 0; i < 4; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
}
}
else { /* Search whole quadrant */
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
if (i & mask)
/* This quadrant may require partial checking */
distance =
distance, found_color, c,
base,
else
/* Here we should check all */
distance =
}
}
}
return distance;
}
/***************************************************************/
const mlib_u32 *c,
{
mlib_s32 i;
{1, 3, 5, 7},
{2, 3, 6, 7},
{4, 5, 6, 7}
};
/* Search only quadrant's half untill it is necessary to check the
whole quadrant */
if (distance <= (c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) { /* Search half of quadrant */
for (i = 0; i < 4; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
distance, found_color, c,
}
}
else { /* Search whole quadrant */
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
if (i & mask)
/* Here we should check all */
distance =
else
/* This quadrant may require partial checking */
distance =
distance, found_color, c,
}
}
}
return distance;
}
/***************************************************************/
{
mlib_s32 i;
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
}
return distance;
}
/***************************************************************/
const mlib_u32 *c,
{
mlib_s32 i;
{0, 2, 4, 6},
{0, 1, 4, 5},
{0, 1, 2, 3}
};
/* Search only quadrant's half untill it is necessary to check the
whole quadrant */
if (distance < (((position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) >> 2)) { /* Search half of quadrant */
for (i = 0; i < 4; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
distance, found_color, c,
}
}
else { /* Search whole quadrant */
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
if (i & mask)
/* This quadrant may require partial checking */
distance =
distance, found_color, c,
base,
else
/* Here we should check all */
distance =
}
}
}
return distance;
}
/***************************************************************/
const mlib_u32 *c,
{
mlib_s32 i;
{1, 3, 5, 7},
{2, 3, 6, 7},
{4, 5, 6, 7}
};
/* Search only quadrant's half untill it is necessary to check the
whole quadrant */
if (distance <= (((c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) >> 2)) { /* Search half of quadrant */
for (i = 0; i < 4; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
distance, found_color, c,
base,
}
}
else { /* Search whole quadrant */
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
if (i & mask)
/* Here we should check all */
distance =
else
/* This quadrant may require partial checking */
distance =
found_color, c, base,
}
}
}
return distance;
}
/***************************************************************/
{
mlib_s32 i;
for (i = 0; i < 16; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
}
return distance;
}
/***************************************************************/
const mlib_u32 *c,
{
mlib_s32 i;
{0, 2, 4, 6, 8, 10, 12, 14},
{0, 1, 4, 5, 8, 9, 12, 13},
{0, 1, 2, 3, 8, 9, 10, 11},
{0, 1, 2, 3, 4, 5, 6, 7}
};
/* Search only quadrant's half untill it is necessary to check the
whole quadrant */
if (distance < (position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) { /* Search half of quadrant */
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
}
}
else { /* Search whole quadrant */
for (i = 0; i < 16; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
if (i & mask)
/* This quadrant may require partial checking */
distance =
distance, found_color, c,
base,
else
/* Here we should check all */
distance =
}
}
}
return distance;
}
/***************************************************************/
const mlib_u32 *c,
{
mlib_s32 i;
{1, 3, 5, 7, 9, 11, 13, 15},
{2, 3, 6, 7, 10, 11, 14, 15},
{4, 5, 6, 7, 12, 13, 14, 15},
{8, 9, 10, 11, 12, 13, 14, 15}
};
/* Search only quadrant's half untill it is necessary to check the
whole quadrant */
if (distance <= (c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) { /* Search half of quadrant */
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
distance, found_color, c,
}
}
else { /* Search whole quadrant */
for (i = 0; i < 16; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
if (i & mask)
/* Here we should check all */
distance =
else
/* This quadrant may require partial checking */
distance =
distance, found_color, c,
}
}
}
return distance;
}
/***************************************************************/
{
mlib_s32 i;
for (i = 0; i < 16; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
}
return distance;
}
/***************************************************************/
const mlib_u32 *c,
{
mlib_s32 i;
{0, 2, 4, 6, 8, 10, 12, 14},
{0, 1, 4, 5, 8, 9, 12, 13},
{0, 1, 2, 3, 8, 9, 10, 11},
{0, 1, 2, 3, 4, 5, 6, 7}
};
/* Search only quadrant's half untill it is necessary to check the
whole quadrant */
if (distance < (((position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) >> 2)) { /* Search half of quadrant */
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
distance, found_color, c,
}
}
else { /* Search whole quadrant */
for (i = 0; i < 16; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
if (i & mask)
/* This quadrant may require partial checking */
distance =
distance, found_color, c,
base,
else
/* Here we should check all */
distance =
}
}
}
return distance;
}
/***************************************************************/
const mlib_u32 *c,
{
mlib_s32 i;
{1, 3, 5, 7, 9, 11, 13, 15},
{2, 3, 6, 7, 10, 11, 14, 15},
{4, 5, 6, 7, 12, 13, 14, 15},
{8, 9, 10, 11, 12, 13, 14, 15}
};
/* Search only quadrant's half untill it is necessary to check the
whole quadrant */
if (distance <= (((c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) >> 2)) { /* Search half of quadrant */
for (i = 0; i < 8; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
distance =
distance, found_color, c,
base,
}
}
else { /* Search whole quadrant */
for (i = 0; i < 16; i++) {
/* Here is alone color cell. Check the distance */
if (distance > newdistance) {
*found_color = newindex;
}
}
if (i & mask)
/* Here we should check all */
distance =
else
/* This quadrant may require partial checking */
distance =
found_color, c, base,
}
}
}
return distance;
}
/***************************************************************/
/***************************************************************/
{ \
mlib_s32 i; \
\
for (i = 0; i < length; i++) { \
} \
}
/***************************************************************/
{ \
mlib_s32 i; \
\
for (i = 0; i < length; i++) { \
src += 4; \
} \
}
/***************************************************************/
const void *state)
{
switch (s->method) {
#if LUT_BYTE_COLORS_3CHANNELS <= 256
case LUT_BINARY_TREE_SEARCH:
{
}
break;
#endif /* LUT_BYTE_COLORS_3CHANNELS <= 256 */
case LUT_COLOR_CUBE_SEARCH:
{
}
break;
case LUT_STUPID_SEARCH:
{
#ifdef USE_VIS_CODE
#else
FIND_NEAREST_U8_3_C(0, 3);
#endif
}
break;
case LUT_COLOR_DIMENSIONS:
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
#if LUT_BYTE_COLORS_3CHANNELS <= 256
case LUT_BINARY_TREE_SEARCH:
{
break;
}
#endif /* LUT_BYTE_COLORS_3CHANNELS <= 256 */
case LUT_COLOR_CUBE_SEARCH:
{
break;
}
case LUT_STUPID_SEARCH:
{
#ifdef USE_VIS_CODE
#else
#endif
break;
}
case LUT_COLOR_DIMENSIONS:
src++;
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
#if LUT_BYTE_COLORS_4CHANNELS <= 256
case LUT_BINARY_TREE_SEARCH:
{
break;
}
#endif /* LUT_BYTE_COLORS_4CHANNELS <= 256 */
case LUT_COLOR_CUBE_SEARCH:
{
break;
}
case LUT_STUPID_SEARCH:
{
#ifdef USE_VIS_CODE
#else
#endif
break;
}
case LUT_COLOR_DIMENSIONS:
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
case LUT_BINARY_TREE_SEARCH:
{
break;
}
case LUT_COLOR_CUBE_SEARCH:
{
switch (s->indexsize) {
case 1:
{
break;
}
case 2:
{
break;
}
}
break;
}
case LUT_STUPID_SEARCH:
{
#ifdef USE_VIS_CODE
#else
FIND_NEAREST_U8_3_C(0, 3);
#endif
break;
}
case LUT_COLOR_DIMENSIONS:
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
case LUT_BINARY_TREE_SEARCH:
{
break;
}
case LUT_COLOR_CUBE_SEARCH:
{
switch (s->indexsize) {
case 1:
{
break;
}
case 2:
{
break;
}
}
break;
}
case LUT_STUPID_SEARCH:
{
#ifdef USE_VIS_CODE
#else
#endif
break;
}
case LUT_COLOR_DIMENSIONS:
src++;
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
case LUT_BINARY_TREE_SEARCH:
{
break;
}
case LUT_COLOR_CUBE_SEARCH:
{
switch (s->indexsize) {
case 1:
{
break;
}
case 2:
{
break;
}
}
break;
}
case LUT_STUPID_SEARCH:
{
#ifdef USE_VIS_CODE
#else
#endif
break;
}
case LUT_COLOR_DIMENSIONS:
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
case LUT_BINARY_TREE_SEARCH:
{
break;
}
case LUT_COLOR_CUBE_SEARCH:
{
switch (s->indexsize) {
case 1:
{
break;
}
case 2:
{
break;
}
}
break;
}
case LUT_STUPID_SEARCH:
{
FIND_NEAREST_S16_3(0, 3);
break;
}
case LUT_COLOR_DIMENSIONS:
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
case LUT_BINARY_TREE_SEARCH:
{
break;
}
case LUT_COLOR_CUBE_SEARCH:
{
switch (s->indexsize) {
case 1:
{
break;
}
case 2:
{
break;
}
}
break;
}
case LUT_STUPID_SEARCH:
{
break;
}
case LUT_COLOR_DIMENSIONS:
src++;
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
case LUT_BINARY_TREE_SEARCH:
{
MLIB_S16_MIN, 2);
break;
}
case LUT_COLOR_CUBE_SEARCH:
{
switch (s->indexsize) {
case 1:
{
break;
}
case 2:
{
break;
}
}
break;
}
case LUT_STUPID_SEARCH:
{
break;
}
case LUT_COLOR_DIMENSIONS:
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
#if LUT_SHORT_COLORS_3CHANNELS <= 256
case LUT_BINARY_TREE_SEARCH:
{
break;
}
#endif /* LUT_SHORT_COLORS_3CHANNELS <= 256 */
case LUT_COLOR_CUBE_SEARCH:
{
break;
}
case LUT_STUPID_SEARCH:
{
FIND_NEAREST_S16_3(0, 3);
break;
}
case LUT_COLOR_DIMENSIONS:
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
#if LUT_SHORT_COLORS_3CHANNELS <= 256
case LUT_BINARY_TREE_SEARCH:
{
break;
}
#endif /* LUT_SHORT_COLORS_3CHANNELS <= 256 */
case LUT_COLOR_CUBE_SEARCH:
{
break;
}
case LUT_STUPID_SEARCH:
{
break;
}
case LUT_COLOR_DIMENSIONS:
src++;
break;
}
}
/***************************************************************/
const void *state)
{
switch (s->method) {
#if LUT_SHORT_COLORS_4CHANNELS <= 256
case LUT_BINARY_TREE_SEARCH:
{
MLIB_S16_MIN, 2);
break;
}
#endif /* LUT_SHORT_COLORS_4CHANNELS <= 256 */
case LUT_COLOR_CUBE_SEARCH:
{
break;
}
case LUT_STUPID_SEARCH:
{
break;
}
case LUT_COLOR_DIMENSIONS:
break;
}
}
/***************************************************************/
#ifndef VIS
void mlib_c_ImageThresh1_U81_1B(void *psrc,
void *pdst,
void *thresh,
void *ghigh,
void *glow,
/***************************************************************/
const void *state)
{
}
#else
/***************************************************************/
/***************************************************************/
const void *state)
{
}
/***************************************************************/
#endif