17f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/*
27f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
37f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
47f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
57f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * you may not use this file except in compliance with the License.
67f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * You may obtain a copy of the License at
77f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
87f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
97f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
107f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software
117f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
127f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * See the License for the specific language governing permissions and
147f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * limitations under the License.
157f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project */
167f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
177f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#ifndef bim_FUNCTIONS_EM_H
187f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#define bim_FUNCTIONS_EM_H
197f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
207f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/**
217f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project * This files contains gerenral purpose functions.
227f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project */
237f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
247f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- includes ----------------------------------------------------------- */
257f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
267f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_BasicEm/UInt8Arr.h"
277f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_TensorEm/Functions.h"
287f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#include "b_TensorEm/Flt16Alt2D.h"
297f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
307f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- related objects  --------------------------------------------------- */
317f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
327f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- typedefs ----------------------------------------------------------- */
337f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
347f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/** pyramidal image type */
357f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectenum bim_PyramidalImageType
367f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project{
377f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bim_UINT8_PYRAMIDAL_IMG,	/* byte representation of pyramical image */
387f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project	bim_UINT16_PYRAMIDAL_IMG	/* 16-bit representation of pyramical image */
397f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project};
407f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
417f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- constants ---------------------------------------------------------- */
427f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
437f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/* ---- external functions ------------------------------------------------- */
447f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
457f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/** Warps an image with intermediate pyramidal downscaling if possible in order to minimize aliasing
467f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  The actual warping happens using pixel interpolation
477f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  *bufPtrA is an intermediate byte array that holds downscaled data (only needed when pyramidal downscaling happens; can be NULL otherwise)
487f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  scaleThresholdA (16.16):
497f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *		specifies the minimum scale ratio (inImage/outImage) required to initiate prior filtering
507f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *      A value range of 2.0...4.0 is recommended (<= 0.0: disabled)
517f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *
527f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  offsPtrA specifies the pixel position (0,0) in the input image (format 16.0)
537f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project */
547f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_filterWarpInterpolation( struct bbs_Context* cpA,
557f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  uint8* dstImagePtrA,
567f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  const uint8* srcImagePtrA,
577f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  uint32 srcImageWidthA,
587f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  uint32 srcImageHeightA,
597f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  const struct bts_Int16Vec2D* offsPtrA,
607f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  const struct bts_Flt16Alt2D* altPtrA,
617f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  uint32 dstWidthA,
627f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  uint32 dstHeightA,
637f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  struct bbs_UInt8Arr* bufPtrA,
647f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								  uint32 scaleThresholdA );
657f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
667f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/** Warps an image with intermediate pyramidal downscaling if possible in order to minimize aliasing
677f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  The actual warping happens using pixel replication (fast but prone to artefacts)
687f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  *bufPtrA is an intermediate byte array that holds downscaled data (only needed when pyramidal downscaling happens; can be NULL otherwise)
697f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  scaleThresholdA (16.16):
707f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *		specifies the minimum scale ratio (inImage/outImage) required to initiate prior filtering
717f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *      A value range of 2.0...4.0 is recommended (0.0: disabled)
727f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  offsPtrA specifies the pixel position (0,0) in the input image (format 16.0)
737f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project */
747f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_filterWarpPixelReplication( struct bbs_Context* cpA,
757f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 uint8* dstImagePtrA,
767f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 const uint8* srcImagePtrA,
777f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 uint32 srcImageWidthA,
787f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 uint32 srcImageHeightA,
797f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project								     const struct bts_Int16Vec2D* offsPtrA,
807f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 const struct bts_Flt16Alt2D* altPtrA,
817f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 uint32 dstWidthA,
827f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 uint32 dstHeightA,
837f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 struct bbs_UInt8Arr* bufPtrA,
847f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project									 uint32 scaleThresholdA );
857f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
867f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project/** Selects proper warp function above
877f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project *  offsPtrA specifies the pixel position (0,0) in the input image (format 16.0)
887f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project */
897f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Projectvoid bim_filterWarp( struct bbs_Context* cpA,
907f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 uint8* dstImagePtrA,
917f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 const uint8* srcImagePtrA,
927f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 uint32 srcImageWidthA,
937f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 uint32 srcImageHeightA,
947f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project  				     const struct bts_Int16Vec2D* offsPtrA,
957f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 const struct bts_Flt16Alt2D* altPtrA,
967f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 uint32 dstWidthA,
977f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 uint32 dstHeightA,
987f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 struct bbs_UInt8Arr* bufPtrA,
997f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 uint32 scaleThresholdA,
1007f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project					 flag interpolateA );
1017f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
1027f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project#endif /* bim_FUNCTIONS_EM_H */
1037f81d9b6fa7f2ec161b682622db577a28c90b49fThe Android Open Source Project
104