本文整理汇总了C++中quantize函数的典型用法代码示例。如果您正苦于以下问题:C++ quantize函数的具体用法?C++ quantize怎么用?C++ quantize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了quantize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ChenZewei,项目名称:shine,代码行数:45,代码来源:l3loop.c
示例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);
}
开发者ID:AndroidStdio,项目名称:PixaToon,代码行数:26,代码来源:filters.cpp
示例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;
}
开发者ID:dyustc,项目名称:Khepera_III,代码行数:45,代码来源:l3loop.c
示例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
}
}
开发者ID:snapbug,项目名称:atire,代码行数:27,代码来源:ranking_function_dph.c
示例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;
}
开发者ID:AbyssSong,项目名称:libsoxrate,代码行数:29,代码来源:threaded_module.c
示例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();
}
}
开发者ID:cadencii,项目名称:cadencii-nt,代码行数:31,代码来源:PianorollTrackView.cpp
示例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;
}
开发者ID:Vertexwahn,项目名称:appleseed-deps,代码行数:27,代码来源:imageio.cpp
示例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;
}
开发者ID:eadordzhiev,项目名称:DjvuLib,代码行数:7,代码来源:DjVuPalette.cpp
示例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);
}
开发者ID:AchimTuran,项目名称:viper4android_fx,代码行数:41,代码来源:g721.c
示例10: quantize
bool KMeansQuantizer::computeFeatures(const VectorFloat &inputVector){
//Run the quantize algorithm
quantize( inputVector );
return true;
}
开发者ID:pscholl,项目名称:grt,代码行数:7,代码来源:KMeansQuantizer.cpp
示例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]);
}
开发者ID:IldefonsoAspera,项目名称:GRABACION,代码行数:33,代码来源:quantizer_main.cpp
示例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;
}
开发者ID:dk00,项目名称:old-stuff,代码行数:27,代码来源:listing3.c
示例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);
}
}
}
开发者ID:UIKit0,项目名称:aqsis,代码行数:28,代码来源:displaymanager.cpp
示例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);
}
开发者ID:Miyaku,项目名称:viper4android_fx,代码行数:40,代码来源:g723_40.c
示例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);
}
开发者ID:GreenIOur,项目名称:ZinJpeg,代码行数:60,代码来源:jpeg.c
示例16: mapToScene
void PianorollTrackView::onMouseMoveSlot(QMouseEvent *event) {
if (mouseStatus.mode == MouseStatus::LEFTBUTTON_SELECT_ITEM) {
mouseStatus.endPosition = mapToScene(event->pos());
updateSelectedItem();
updateWidget();
} else if (mouseStatus.mode == MouseStatus::MIDDLEBUTTON_SCROLL) {
QPoint globalMousePos = ui->mainContent->mapToGlobal(event->pos());
int deltaX = globalMousePos.x() - mouseStatus.globalStartPosition.x();
int deltaY = globalMousePos.y() - mouseStatus.globalStartPosition.y();
ui->mainContent->horizontalScrollBar()
->setValue(mouseStatus.horizontalScrollStartValue - deltaX);
ui->mainContent->verticalScrollBar()
->setValue(mouseStatus.verticalScrollStartValue - deltaY);
updateWidget();
} else if (mouseStatus.mode == MouseStatus::LEFTBUTTON_MOVE_ITEM) {
QPoint currentMousePos = mapToScene(event->pos());
// マウスの移動量から、クロック・ノートの移動量を算出
VSQ_NS::tick_t deltaClocks = controllerAdapter->getTickFromX(currentMousePos.x())
- controllerAdapter->getTickFromX(mouseStatus.startPosition.x());
if (mouseStatus.noteOnMouse) {
VSQ_NS::tick_t editedNoteClock
= quantize(mouseStatus.noteOnMouse->clock + deltaClocks);
deltaClocks = editedNoteClock - mouseStatus.noteOnMouse->clock;
}
int deltaNoteNumbers = getNoteNumberFromY(currentMousePos.y(), trackHeight)
- getNoteNumberFromY(mouseStatus.startPosition.y(), trackHeight);
// 選択されたアイテムすべてについて、移動を適用する
ItemSelectionManager *manager = controllerAdapter->getItemSelectionManager();
manager->moveItems(deltaClocks, deltaNoteNumbers);
updateWidget();
} else if (mouseStatus.mode == MouseStatus::LEFTBUTTON_ADD_ITEM) {
QPoint currentMousePos = mapToScene(event->pos());
VSQ_NS::tick_t endClock = controllerAdapter->getTickFromX(currentMousePos.x());
VSQ_NS::tick_t length = 0;
if (mouseStatus.addingNoteItem.clock < endClock) {
length = endClock - mouseStatus.addingNoteItem.clock;
length = quantize(length);
}
mouseStatus.addingNoteItem.setLength(length);
updateWidget();
}
mouseStatus.isMouseMoved = true;
}
开发者ID:cadencii,项目名称:cadencii-nt,代码行数:46,代码来源:PianorollTrackView.cpp
示例17: while
/*
ANT_RANKING_FUNCTION_PUURULA_IDF::RELEVANCE_RANK_TOP_K()
--------------------------------------------------------
*/
void ANT_ranking_function_puurula_idf::relevance_rank_top_k(ANT_search_engine_result *accumulator, ANT_search_engine_btree_leaf *term_details, ANT_impact_header *impact_header, ANT_compressable_integer *impact_ordering, long long trim_point, double prescalar, double postscalar, double query_frequency)
{
long long docid;
double rsv, tf, query_length, query_occurences, prior;
ANT_compressable_integer *current, *end;
query_length = accumulator->get_term_count();
query_occurences = query_frequency; // this has already been transformed by the TFxIDF equation.
impact_header->impact_value_ptr = impact_header->impact_value_start;
impact_header->doc_count_ptr = impact_header->doc_count_start;
current = impact_ordering;
while (impact_header->doc_count_ptr < impact_header->doc_count_trim_ptr)
{
docid = -1;
end = current + *impact_header->doc_count_ptr;
while (current < end)
{
docid += *current++;
tf = *impact_header->impact_value_ptr;
tf = log(1.0 + tf / unique_terms_in_document[docid]) * log((double)documents / (double)term_details->global_document_frequency); // L0 norm version
tf = max(tf - g * pow(tf, g), 0);
if (tf != 0)
{
/*
There must be some TF component to the score or else the rsv == 0 which is equivelant to the term not occuring
*/
rsv = query_occurences * log((tf * unique_terms_in_collection) / u + 1.0);
if (accumulator->is_zero_rsv(docid)) // unseen before now so add the document prior
{
prior = log(1.0 - discounted_document_lengths[(size_t)docid] / (tfidf_discounted_document_lengths[(size_t)docid] + u));
accumulator->add_rsv(docid, quantize(query_length * prior + rsv, maximum_collection_rsv, minimum_collection_rsv));
}
else // seen so we have already added the prior
accumulator->add_rsv(docid, quantize(rsv, maximum_collection_rsv, minimum_collection_rsv));
}
}
current = end;
impact_header->impact_value_ptr++;
impact_header->doc_count_ptr++;
}
#pragma ANT_PRAGMA_UNUSED_PARAMETER
}
开发者ID:snapbug,项目名称:atire,代码行数:49,代码来源:ranking_function_puurula_idf.c
示例18: detectPreamble
/* Identify preamble sequence */
bool detectPreamble(void)
{
int transitions = 0;
int c;
// preamble sequence is based on the 9th symbol (either 0x55 or 0xAA)
if (quantize(9)) {
for (c = 0; c < 8; c++) {
transitions += quantize(c) > quantize(c + 1);
}
} else {
for (c = 0; c < 8; c++) {
transitions += quantize(c) < quantize(c + 1);
}
}
return transitions == 4 && abs(_threshold) < 15500;
}
开发者ID:sghctoma,项目名称:antfs-poc-defcon24,代码行数:19,代码来源:ShockBurstUtils.hpp
示例19: extractByte
/* Extract byte from ring buffer starting location l */
inline uint8_t extractByte(int l)
{
uint8_t byte = 0;
int c;
for (c = 0; c < 8; c++) {
byte |= quantize(l + c) << (7 - c);
}
return byte;
}
开发者ID:sghctoma,项目名称:antfs-poc-defcon24,代码行数:11,代码来源:ShockBurstUtils.hpp
示例20: normalize
void MotionRecognizer::addLearningData(vector<kmVecPair> &data, Motion motion)
{
vector<unsigned long> *seq = new vector<unsigned long>();
vector<kmVec3> norm;
normalize(data, norm);
quantize(norm, *seq);
// Save it to buffer
m_sequences[motion].push_back(seq);
}
开发者ID:pramodwadkar,项目名称:RealFighter,代码行数:11,代码来源:MotionRecognizer.cpp
注:本文中的quantize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论