2007-03-08 04:03:40 +08:00
|
|
|
/**********************************************************************
|
|
|
|
* File: pithsync.h (Formerly pitsync2.h)
|
|
|
|
* Description: Code to find the optimum fixed pitch segmentation of some blobs.
|
|
|
|
* Author: Ray Smith
|
|
|
|
* Created: Thu Nov 19 11:48:05 GMT 1992
|
|
|
|
*
|
|
|
|
* (C) Copyright 1992, Hewlett-Packard Ltd.
|
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef PITHSYNC_H
|
|
|
|
#define PITHSYNC_H
|
|
|
|
|
|
|
|
#include "blobbox.h"
|
2010-11-24 02:34:14 +08:00
|
|
|
#include "params.h"
|
2007-03-08 04:03:40 +08:00
|
|
|
#include "statistc.h"
|
|
|
|
|
|
|
|
class FPSEGPT_LIST;
|
|
|
|
|
|
|
|
class FPCUTPT
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FPCUTPT() { //empty
|
|
|
|
}
|
|
|
|
void setup ( //start of cut
|
|
|
|
FPCUTPT cutpts[], //predecessors
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 array_origin, //start coord
|
2007-03-08 04:03:40 +08:00
|
|
|
STATS * projection, //occupation
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 zero_count, //official zero
|
|
|
|
inT16 pitch, //proposed pitch
|
|
|
|
inT16 x, //position
|
|
|
|
inT16 offset); //dist to gap
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
void assign ( //evaluate cut
|
|
|
|
FPCUTPT cutpts[], //predecessors
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 array_origin, //start coord
|
|
|
|
inT16 x, //position
|
2007-03-08 04:03:40 +08:00
|
|
|
BOOL8 faking, //faking this one
|
|
|
|
BOOL8 mid_cut, //doing free cut
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 offset, //extra cost dist
|
2007-03-08 04:03:40 +08:00
|
|
|
STATS * projection, //occupation
|
|
|
|
float projection_scale, //scaling
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 zero_count, //official zero
|
|
|
|
inT16 pitch, //proposed pitch
|
|
|
|
inT16 pitch_error); //allowed tolerance
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
void assign_cheap ( //evaluate cut
|
|
|
|
FPCUTPT cutpts[], //predecessors
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 array_origin, //start coord
|
|
|
|
inT16 x, //position
|
2007-03-08 04:03:40 +08:00
|
|
|
BOOL8 faking, //faking this one
|
|
|
|
BOOL8 mid_cut, //doing free cut
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 offset, //extra cost dist
|
2007-03-08 04:03:40 +08:00
|
|
|
STATS * projection, //occupation
|
|
|
|
float projection_scale, //scaling
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 zero_count, //official zero
|
|
|
|
inT16 pitch, //proposed pitch
|
|
|
|
inT16 pitch_error); //allowed tolerance
|
2007-03-08 04:03:40 +08:00
|
|
|
|
2015-11-04 16:53:38 +08:00
|
|
|
inT32 position() { //access func
|
2007-03-08 04:03:40 +08:00
|
|
|
return xpos;
|
|
|
|
}
|
2008-04-22 08:34:11 +08:00
|
|
|
double cost_function() {
|
2007-03-08 04:03:40 +08:00
|
|
|
return cost;
|
|
|
|
}
|
2008-04-22 08:34:11 +08:00
|
|
|
double squares() {
|
2007-03-08 04:03:40 +08:00
|
|
|
return sq_sum;
|
|
|
|
}
|
2008-04-22 08:34:11 +08:00
|
|
|
double sum() {
|
2007-03-08 04:03:40 +08:00
|
|
|
return mean_sum;
|
|
|
|
}
|
2008-04-22 08:34:11 +08:00
|
|
|
FPCUTPT *previous() {
|
2007-03-08 04:03:40 +08:00
|
|
|
return pred;
|
|
|
|
}
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 cheap_cuts() const { //no of mi cuts
|
2007-03-08 04:03:40 +08:00
|
|
|
return mid_cuts;
|
|
|
|
}
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 index() const {
|
2007-03-08 04:03:40 +08:00
|
|
|
return region_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL8 faked; //faked split point
|
|
|
|
BOOL8 terminal; //successful end
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 fake_count; //total fakes to here
|
2007-03-08 04:03:40 +08:00
|
|
|
|
|
|
|
private:
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 region_index; //cut serial number
|
|
|
|
inT16 mid_cuts; //no of cheap cuts
|
|
|
|
inT32 xpos; //location
|
|
|
|
uinT32 back_balance; //proj backwards
|
|
|
|
uinT32 fwd_balance; //proj forwards
|
2007-03-08 04:03:40 +08:00
|
|
|
FPCUTPT *pred; //optimal previous
|
|
|
|
double mean_sum; //mean so far
|
|
|
|
double sq_sum; //summed distsances
|
|
|
|
double cost; //cost function
|
|
|
|
};
|
|
|
|
double check_pitch_sync2( //find segmentation
|
|
|
|
BLOBNBOX_IT *blob_it, //blobs to do
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 blob_count, //no of blobs
|
|
|
|
inT16 pitch, //pitch estimate
|
|
|
|
inT16 pitch_error, //tolerance
|
2007-03-08 04:03:40 +08:00
|
|
|
STATS *projection, //vertical
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 projection_left, //edges //scale factor
|
|
|
|
inT16 projection_right,
|
2007-03-08 04:03:40 +08:00
|
|
|
float projection_scale,
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 &occupation_count, //no of occupied cells
|
2007-03-08 04:03:40 +08:00
|
|
|
FPSEGPT_LIST *seg_list, //output list
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 start, //start of good range
|
|
|
|
inT16 end //end of good range
|
2007-03-08 04:03:40 +08:00
|
|
|
);
|
|
|
|
double check_pitch_sync3( //find segmentation
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 projection_left, //edges //to be considered 0
|
|
|
|
inT16 projection_right,
|
|
|
|
inT16 zero_count,
|
|
|
|
inT16 pitch, //pitch estimate
|
|
|
|
inT16 pitch_error, //tolerance
|
2007-03-08 04:03:40 +08:00
|
|
|
STATS *projection, //vertical
|
|
|
|
float projection_scale, //scale factor
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 &occupation_count, //no of occupied cells
|
2007-03-08 04:03:40 +08:00
|
|
|
FPSEGPT_LIST *seg_list, //output list
|
2008-04-22 08:34:11 +08:00
|
|
|
inT16 start, //start of good range
|
|
|
|
inT16 end //end of good range
|
2007-03-08 04:03:40 +08:00
|
|
|
);
|
|
|
|
#endif
|