cvmorphing.cpp.svn-base
来自「非结构化路识别」· SVN-BASE 代码 · 共 397 行 · 第 1/2 页
SVN-BASE
397 行
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "_cv.h"
#include <assert.h>
CvStatus
icvMorphEpilines8uC3( uchar * first_pix, /* raster epiline from image 1 */
uchar * second_pix, /* raster epiline from image 2 */
uchar * dst_pix, /* raster epiline from dest image */
/* (it's an output parameter) */
float alpha, /* relative position of camera */
int *first, /* first sequence of runs */
int first_runs, /* it's length */
int *second, /* second sequence of runs */
int second_runs, int *first_corr, /* corr data for the 1st seq */
int *second_corr, /* corr data for the 2nd seq */
int dst_len )
{
float alpha1; /* alpha - 1.0 */
int s, s1; /* integer variant of alpha and alpha1 ( 0 <= s,s1 <= 256 ) */
int curr; /* current index in run's array */
float begLine; /* begin of current run */
float endLine; /* end of current run */
float begCorr; /* begin of correspondence destination of run */
float endCorr; /* end of correspondence destination of run */
int begDestLine; /* begin of current destanation of run */
int endDestLine; /* end of current destanation of run */
int begLineIndex;
int endLineIndex;
int indexImg1;
float step = 0;
int n;
memset( dst_pix, 0, dst_len );
alpha1 = (float) (1.0 - alpha);
s = (int) (alpha * 256);
s1 = 256 - s;
/* --------------Create first line------------- */
begLineIndex = first[0];
begLine = (float) begLineIndex;
curr = 0;
for( n = 0; n < first_runs; n++ )
{ /* for each run */
begCorr = (float) first_corr[curr];
curr++;
endCorr = (float) first_corr[curr];
curr++;
endLineIndex = first[curr];
endLine = (float) endLineIndex;
begDestLine = (int) (alpha * begLine + alpha1 * begCorr);
endDestLine = (int) (alpha * endLine + alpha1 * endCorr);
indexImg1 = begDestLine * 3;
step = 0;
if( endDestLine != begDestLine )
step = (endLine - begLine) / ((float) (endDestLine - begDestLine));
if( begCorr != endCorr )
{
for( ; begDestLine < endDestLine; begDestLine++ )
{
/* for each pixel */
begLineIndex = (int) begLine;
begLineIndex *= 3;
/* Blend R */
dst_pix[indexImg1] = (uchar) (((int) (first_pix[begLineIndex]) * s) >> 8);
indexImg1++;
/* Blend G */
dst_pix[indexImg1] = (uchar) (((int) (first_pix[begLineIndex + 1]) * s) >> 8);
indexImg1++;
/* Blend B */
dst_pix[indexImg1] = (uchar) (((int) (first_pix[begLineIndex + 2]) * s) >> 8);
indexImg1++;
begLine += step;
} /* for */
}
else
{
for( ; begDestLine < endDestLine; begDestLine++ )
{
/* for each pixel */
begLineIndex = (int) begLine;
begLineIndex *= 3;
/* Blend R */
dst_pix[indexImg1] = first_pix[begLineIndex];
indexImg1++;
/* Blend G */
dst_pix[indexImg1] = first_pix[begLineIndex + 1];
indexImg1++;
/* Blend B */
dst_pix[indexImg1] = first_pix[begLineIndex + 2];
indexImg1++;
begLine += step;
} /* for */
} /* if */
begLineIndex = endLineIndex;
begLine = endLine;
} /* for each runs in first line */
begLineIndex = second[0];
begLine = (float) begLineIndex;
curr = 0;
/* --------------Create second line------------- */
curr = 0;;
for( n = 0; n < second_runs; n++ )
{ /* for each run */
begCorr = (float) second_corr[curr];
curr++;
endCorr = (float) second_corr[curr];
curr++;
endLineIndex = second[curr];
endLine = (float) endLineIndex;
begDestLine = (int) (alpha1 * begLine + alpha * begCorr);
endDestLine = (int) (alpha1 * endLine + alpha * endCorr);
indexImg1 = begDestLine * 3;
step = 0;
if (endDestLine != begDestLine)
step = (endLine - begLine) / ((float) (endDestLine - begDestLine));
if( begCorr != endCorr )
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?