本文整理汇总了C++中quantize函数的典型用法代码示例。如果您正苦于以下问题:C++ quantize函数的具体用法?C++ quantize怎么用?C++ quantize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quantize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bin_search_StepSize
/*
* bin_search_StepSize:
* --------------------
* Succesive approximation approach to obtaining a initial quantizer
* step size.
* The following optional code written by Seymour Shlien
* will speed up the shine_outer_loop code which is called
* by iteration_loop. When BIN_SEARCH is defined, the
* shine_outer_loop function precedes the call to the function shine_inner_loop
* with a call to bin_search gain defined below, which
* returns a good starting quantizerStepSize.
*/
int bin_search_StepSize(int desired_rate, int ix[GRANULE_SIZE],
gr_info * cod_info, shine_global_config *config)
{
int bit, next, count;
next = -120;
count = 120;
do {
int half = count / 2;
if (quantize(ix, next + half, config) > 8192)
bit = 100000; /* fail */
else
{
calc_runlen(ix, cod_info); /* rzero,count1,big_values */
bit = count1_bitcount(ix, cod_info); /* count1_table selection */
subdivide(cod_info, config); /* bigvalues sfb division */
bigv_tab_select(ix, cod_info); /* codebook selection */
bit += bigv_bitcount(ix, cod_info); /* bit count */
}
if (bit < desired_rate)
count = half;
else
{
next += half;
count -= half;
}
} while (count > 1);
return next;
}
示例2: colorCartoonFilter
/* Color-Cartoon Filter Imaplementation */
void colorCartoonFilter(Mat& src, Mat& dst, int edgeThickness, int edgeThreshold)
{
// denormalize params
edgeThickness = (edgeThickness*(CARTOON_THICK_MAX - CARTOON_THICK_MIN))/INPUT_MAX + CARTOON_THICK_MIN;
if(edgeThickness%2 == 0) edgeThickness++;
edgeThreshold = (edgeThreshold*(CARTOON_THRESH_MAX - CARTOON_THRESH_MIN))/INPUT_MAX + CARTOON_THRESH_MIN;
Mat src_blurred, src_gray, quantized, edges;
// Denoise image
GaussianBlur(src, src_blurred, Size(5,5), 0);
// Get src image grayscale
cvtColor(src_blurred, src_gray, CV_RGBA2GRAY);
// Quantize gray img to get discrete shades
quantize(src_gray, quantized);
cvtColor(quantized, dst, CV_GRAY2RGBA);
// superimpose gray shades on color src img
//subtract(src_blurred, ~dst, dst);
add(0.7*src_blurred,0.7*dst,dst);
// get illumination-resistant edges by adaptive thresholding
adaptiveThreshold(src_gray, src_gray, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, edgeThickness, edgeThreshold);
cvtColor(src_gray, edges, CV_GRAY2RGBA);
// superimpose edges on shaded src img
subtract(dst, ~edges, dst);
}
示例3: bin_search_StepSize
/*
* bin_search_StepSize:
* --------------------
* Succesive approximation approach to obtaining a initial quantizer
* step size.
* The following optional code written by Seymour Shlien
* will speed up the outer_loop code which is called
* by iteration_loop. When BIN_SEARCH is defined, the
* outer_loop function precedes the call to the function inner_loop
* with a call to bin_search gain defined below, which
* returns a good starting quantizerStepSize.
*/
int bin_search_StepSize(int desired_rate, int ix[samp_per_frame2],
gr_info * cod_info)
{
int top,bot,next,last,bit;
top = -120;
bot = 0;
next = top;
do
{
last = next;
next = (top+bot) >> 1;
if(quantize(ix,next) > 8192)
bit = 100000; /* fail */
else
{
calc_runlen(ix,cod_info); /* rzero,count1,big_values */
bit = count1_bitcount(ix, cod_info); /* count1_table selection */
subdivide(cod_info); /* bigvalues sfb division */
bigv_tab_select(ix,cod_info); /* codebook selection */
bit += bigv_bitcount(ix,cod_info); /* bit count */
}
if (bit>desired_rate)
top = next;
else
bot = next;
}
while((bit!=desired_rate) && abs(last-next)>1);
return next;
}
示例4: while
void ANT_ranking_function_DPH::relevance_rank_top_k(ANT_search_engine_result *accumulator, ANT_search_engine_btree_leaf *term_details, ANT_compressable_integer *impact_ordering, long long trim_point, double prescalar, double postscalar, double query_frequency)
{
long long docid;
double f, norm, tf, cf, score;
ANT_compressable_integer *current, *end;
current = impact_ordering;
end = impact_ordering + (term_details->local_document_frequency >= trim_point ? trim_point : term_details->local_document_frequency);
cf = (double)term_details->global_collection_frequency;
while (current < end)
{
end += 2; // account for the impact_order and the terminator
tf = *current++ * prescalar;
docid = -1;
while (*current != 0)
{
docid += *current++;
f = tf / document_lengths[(size_t)docid];
norm = (1.0 - f) * (1.0 - f) / (tf + 1.0);
score = 1.0 * norm * (tf * ANT_log2((tf * mean_document_length / document_lengths[(size_t)docid]) * (documents / cf)) + 0.5 * ANT_log2(2.0 * M_PI * tf * (1.0 - f)));
accumulator->add_rsv(docid, quantize(postscalar * score, maximum_collection_rsv, minimum_collection_rsv));
}
current++; // skip over the zero
}
}
示例5: lsx_process_threaded_noninterleaved
int lsx_process_threaded_noninterleaved(lsx_thread_state_t *state,
const float * const *ibuf,
float **obuf,
size_t *ilen, size_t *olen,
size_t istride, size_t ostride)
{
int n;
size_t i;
size_t count = ilen ? min(*ilen, IO_BUFSIZE) : 0;
for (n = 0; n < state->count; ++n) {
state->pth[n].ilen = count;
state->pth[n].olen = min(*olen, IO_BUFSIZE);
}
for (n = 0; n < state->count; ++n)
for (i = 0; i < count; ++i)
state->pth[n].ibuf[i] = ibuf[n][i * istride];
if (run_filter(state) < 0)
return -1;
for (n = 0; n < state->count; ++n)
for (i = 0; i < state->pth[0].olen; ++i)
obuf[n][i * ostride] = quantize(state->pth[n].obuf[i]);
if (ilen && *ilen)
*ilen = state->pth[0].ilen;
*olen = state->pth[0].olen;
return 0;
}
示例6: findNoteEventAt
void PianorollTrackView::handleMouseLeftButtonPressByPencil(QMouseEvent *event) {
const VSQ_NS::Event *noteEventOnMouse = findNoteEventAt(event->pos());
if (noteEventOnMouse) {
initMouseStatus(MouseStatus::LEFTBUTTON_MOVE_ITEM, event, noteEventOnMouse);
ItemSelectionManager *manager = controllerAdapter->getItemSelectionManager();
if ((event->modifiers() & Qt::ControlModifier) != Qt::ControlModifier) {
manager->clear();
}
manager->add(noteEventOnMouse);
updateWidget();
} else {
ItemSelectionManager *manager = controllerAdapter->getItemSelectionManager();
bool repaint = false;
if (!manager->getEventItemList()->empty()) {
manager->clear();
repaint = true;
}
initMouseStatus(MouseStatus::LEFTBUTTON_ADD_ITEM, event, noteEventOnMouse);
QPoint mousePosition = mapToScene(event->pos());
int note = getNoteNumberFromY(mousePosition.y(), trackHeight);
VSQ_NS::tick_t clock = controllerAdapter->getTickFromX(mousePosition.x());
clock = quantize(clock);
mouseStatus.addingNoteItem = VSQ_NS::Event(clock, VSQ_NS::EventType::NOTE);
mouseStatus.addingNoteItem.note = note;
hideLyricEdit();
if (repaint) updateWidget();
}
}
示例7: _from_float
const void *
_from_float (const float *src, T *dst, size_t nvals,
long long quant_min, long long quant_max)
{
if (! src) {
// If no source pixels, assume zeroes
T z = T(0);
for (size_t p = 0; p < nvals; ++p)
dst[p] = z;
} else if (std::numeric_limits <T>::is_integer) {
// Convert float to non-float native format, with quantization
for (size_t p = 0; p < nvals; ++p)
dst[p] = (T) quantize (src[p], quant_min, quant_max);
} else {
// It's a floating-point type of some kind -- we don't apply
// quantization
if (sizeof(T) == sizeof(float)) {
// It's already float -- return the source itself
return src;
}
// Otherwise, it's converting between two fp types
for (size_t p = 0; p < nvals; ++p)
dst[p] = (T) src[p];
}
return dst;
}
示例8: compute_pixmap_palette
int
DjVuPalette::compute_palette_and_quantize(GPixmap &pm, int maxcolors, int minboxsize)
{
int result = compute_pixmap_palette(pm, maxcolors, minboxsize);
quantize(pm);
return result;
}
示例9: g721_encoder
/*
* g721_encoder()
*
* Encodes the input vale of linear PCM, A-law or u-law data sl and returns
* the resulting code. -1 is returned for unknown input coding value.
*/
int
g721_encoder(
int sl,
G72x_STATE *state_ptr)
{
short sezi, se, sez; /* ACCUM */
short d; /* SUBTA */
short sr; /* ADDB */
short y; /* MIX */
short dqsez; /* ADDC */
short dq, i;
/* linearize input sample to 14-bit PCM */
sl >>= 2; /* 14-bit dynamic range */
sezi = predictor_zero(state_ptr);
sez = sezi >> 1;
se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */
d = sl - se; /* estimation difference */
/* quantize the prediction difference */
y = step_size(state_ptr); /* quantizer step size */
i = quantize(d, y, qtab_721, 7); /* i = ADPCM code */
dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized est diff */
sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */
dqsez = sr + sez - se; /* pole prediction diff. */
update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
return (i);
}
示例10: quantize
bool KMeansQuantizer::computeFeatures(const VectorFloat &inputVector){
//Run the quantize algorithm
quantize( inputVector );
return true;
}
示例11: main
int main(int argc, char **argv)
{
FILE *files[64];
int numFiles = 0;
for(int i = 2; i < argc; i++){
files[numFiles] = fopen(argv[i], "r");
numFiles++;
}
if(argv[1][0] == 'q'){
fvec centroids[3];
fvec variances;
quantize(numFiles, files, 3, centroids, variances);
cout<<variances(0);
for(int i = 1; i < F0_FEATURES; i++)
cout<<","<<variances(i);
cout<<endl;
for(int j = 0; j < 3; j++){
cout<<centroids[j](0);
for(int i = 1; i < F0_FEATURES; i++)
cout<<","<<centroids[j](i);
cout<<endl;
}
}
else if(argv[1][0] == 't'){
cout<<"decided on "<<test(files[0], numFiles - 1, &files[1])<<endl;
}
for(int i = 0; i < numFiles; i++)
fclose(files[i]);
}
示例12: main
int main()
{
tga_image tga;
double dct_buf[8][8];
int i, j, k, l;
load_tga(&tga, "in.tga");
k = 0;
l = (tga.height / 8) * (tga.width / 8);
for (j=0; j<tga.height/8; j++)
for (i=0; i<tga.width/8; i++)
{
dct(&tga, dct_buf, i*8, j*8);
quantize(dct_buf);
idct(&tga, dct_buf, i*8, j*8);
printf("processed %d/%d blocks.\r", ++k,l);
fflush(stdout);
}
printf("\n");
DONTFAIL( tga_write_mono("out.tga", tga.image_data,
tga.width, tga.height) );
tga_free_buffers(&tga);
return EXIT_SUCCESS;
}
示例13: prod
void DisplayManager::writeTile(V2i pos, const float* data)
{
int nPixels = prod(m_tileSize);
for(int idisp = 0; idisp < (int)m_displayInfo.size(); ++idisp)
{
DisplayData& dispInfo = m_displayInfo[idisp];
int nChans = dispInfo.var.scalarSize();
ConstFvecView src(data + dispInfo.var.offset, nChans, m_totChans);
if(dispInfo.quantize)
{
// Quantize into temporary buffer
uint8* tmpTile = static_cast<uint8*>(
tmpStorage(nChans*nPixels*sizeof(uint8)));
quantize(src, prod(m_tileSize), tmpTile);
LockGuard lk(m_mutex);
dispInfo.display->writeTile(pos, tmpTile);
}
else
{
// Copy over channels directly.
float* tmpTile = static_cast<float*>(
tmpStorage(nChans*nPixels*sizeof(float)));
copy(FvecView(tmpTile, nChans), src, nPixels);
LockGuard lk(m_mutex);
dispInfo.display->writeTile(pos, tmpTile);
}
}
}
示例14: g723_40_encoder
/*
* g723_40_encoder()
*
* Encodes a 16-bit linear PCM, A-law or u-law input sample and retuens
* the resulting 5-bit CCITT G.723 40Kbps code.
* Returns -1 if the input coding value is invalid.
*/
int g723_40_encoder (int sl, G72x_STATE *state_ptr)
{
short sei, sezi, se, sez; /* ACCUM */
short d; /* SUBTA */
short y; /* MIX */
short sr; /* ADDB */
short dqsez; /* ADDC */
short dq, i;
/* linearize input sample to 14-bit PCM */
sl >>= 2; /* sl of 14-bit dynamic range */
sezi = predictor_zero(state_ptr);
sez = sezi >> 1;
sei = sezi + predictor_pole(state_ptr);
se = sei >> 1; /* se = estimated signal */
d = sl - se; /* d = estimation difference */
/* quantize prediction difference */
y = step_size(state_ptr); /* adaptive quantizer step size */
i = quantize(d, y, qtab_723_40, 15); /* i = ADPCM code */
dq = reconstruct(i & 0x10, _dqlntab[i], y); /* quantized diff */
sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */
dqsez = sr + sez - se; /* dqsez = pole prediction diff. */
update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
return (i);
}
示例15: huffman_encode
/******************************************************************************
** huffman_encode
** --------------------------------------------------------------------------
** Quantize and Encode a 8x8 DCT block by JPEG Huffman lossless coding.
** This function writes encoded bit-stream into bit-buffer.
**
** ARGUMENTS:
** ctx - pointer to encoder context;
** data - pointer to 8x8 DCT block;
**
** RETURN: -
******************************************************************************/
void huffman_encode(huffman_t *const ctx, const short data[], unsigned block_num)
{
unsigned magn, bits;
unsigned zerorun, i;
short diff;
short dc = quantize(data[0], ctx->qtable[0]);
// WARNING: in order to everything to work correctly
// the get_DC_value must be called before the block_start
// otherwise it returns a wrong DC value in case of megablocks
// (the block_start reset the force_marker variable, which is
// used by get_DC_value
diff = get_DC_value(dc, block_num);
block_start(block_num);
bits = huffman_bits(diff);
magn = huffman_magnitude(diff);
add_to_block(ctx->hdcbit[magn], ctx->hdclen[magn]);
add_to_block(bits, magn);
for (zerorun = 0, i = 1; i < 64; i++)
{
const short ac = quantize(data[zig[i]], ctx->qtable[zig[i]]);
if (ac) {
while (zerorun >= 16) {
zerorun -= 16;
// ZRL
add_to_block(ctx->hacbit[15][0], ctx->haclen[15][0]);
}
bits = huffman_bits(ac);
magn = huffman_magnitude(ac);
add_to_block(ctx->hacbit[zerorun][magn], ctx->haclen[zerorun][magn]);
add_to_block(bits, magn);
zerorun = 0;
}
else zerorun++;
}
if (zerorun) { // EOB - End Of Block
add_to_block(ctx->hacbit[0][0], ctx->haclen[0][0]);
}
block_end(&bitbuf);
}