本文整理汇总了C++中image::end方法的典型用法代码示例。如果您正苦于以下问题:C++ image::end方法的具体用法?C++ image::end怎么用?C++ image::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image
的用法示例。
在下文中一共展示了image::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMax
bool brightRGB::getMax(const image& img,dvector& dest) const{
// image empty?
if (img.empty()) {
setStatusString("image empty");
dest.resize(0);
return false;
}
const rgbPixel transColor = getParameters().transColor;
ivector maxV(3,-1);
image::const_iterator it = img.begin();
if(getParameters().transparent) {
while(it != img.end()) {
if(*it != transColor) {
if((*it).getRed() > maxV.at(0))
maxV.at(0) = (*it).getRed();
if((*it).getGreen() > maxV.at(1))
maxV.at(1) = (*it).getGreen();
if((*it).getBlue() > maxV.at(2))
maxV.at(2) = (*it).getBlue();
}
it++;
}
// only transparent pixels?
if (maxV.at(0)==-1) {
setStatusString("only transparent pixels");
dest.resize(0);
return false;
}
} else { // no transparent color
while(it != img.end()) {
if((*it).getRed() > maxV.at(0))
maxV.at(0) = (*it).getRed();
if((*it).getGreen() > maxV.at(1))
maxV.at(1) = (*it).getGreen();
if((*it).getBlue() > maxV.at(2))
maxV.at(2) = (*it).getBlue();
it++;
}
}
if(maxV.at(0) == -1)
return false;
dest.castFrom(maxV);
// normalize to 0..1
dest.divide(255);
return true;
};
示例2: getAverage
bool brightRGB::getAverage(const image& img,dvector& dest) const{
const rgbPixel transColor = getParameters().transColor;
dvector avg(3,0.0);
image::const_iterator it = img.begin();
// check for empty image
if (img.columns()==0 || img.rows()==0) {
setStatusString("image empty");
dest.resize(0);
return false;
}
if(getParameters().transparent) {
int counter = 0;
while(it != img.end()) {
if(*it != transColor) {
avg.at(0) += (*it).getRed();
avg.at(1) += (*it).getGreen();
avg.at(2) += (*it).getBlue();
++counter;
}
it++;
}
// check for completely transparent image
if (counter==0) {
setStatusString("only transparent pixels");
dest.resize(0);
return false;
}
avg.divide(counter);
} else { // no transparent color
while(it != img.end()) {
avg.at(0) += (*it).getRed();
avg.at(1) += (*it).getGreen();
avg.at(2) += (*it).getBlue();
it++;
}
avg.divide(img.columns()*img.rows());
}
// values between 0 and 1
dest.divide(avg, 255.);
return true;
};
示例3: begin
image::image(const image& src)
{
_alloc(src.width(), src.height());
std::copy(src.begin(), src.end(), begin());
}
示例4: getMedian
bool brightRGB::getMedian(const image& img,dvector& dest) const{
// image empty?
if (img.empty()) {
setStatusString("image empty");
dest.resize(0);
return false;
}
const rgbPixel transColor = getParameters().transColor;
dest.resize(3);
ivector hist0(256,0);
ivector hist1(256,0);
ivector hist2(256,0);
image::const_iterator it = img.begin();
if(getParameters().transparent) {
while(it != img.end()) {
if(*it != transColor) {
++hist0.at((*it).getRed());
++hist1.at((*it).getGreen());
++hist2.at((*it).getBlue());
}
it++;
}
const int counterHalf = hist0.sumOfElements()/2;
// check for complete image transparent
if (counterHalf==0) {
setStatusString("only transparent pixels");
dest.resize(0);
return false;
}
int i,s;
i=-1,s=0;
while(++i<256 && s<counterHalf) {
s += hist0.at(i);
}
dest.at(0) = i-1;
i=-1,s=0;
while(++i<256 && s<counterHalf) {
s += hist1.at(i);
}
dest.at(1) = i-1;
i=-1,s=0;
while(++i<256 && s<counterHalf) {
s += hist2.at(i);
}
dest.at(2) = i-1;
} else { // no transparent color
while(it != img.end()) {
++hist0.at((*it).getRed());
++hist1.at((*it).getGreen());
++hist2.at((*it).getBlue());
it++;
}
const int counterHalf = img.columns()*img.rows()/2;
int i,s;
i=-1,s=0;
while(++i<256 && s<counterHalf) {
s += hist0.at(i);
}
dest.at(0) = i-1;
i=-1,s=0;
while(++i<256 && s<counterHalf) {
s += hist1.at(i);
}
dest.at(1) = i-1;
i=-1,s=0;
while(++i<256 && s<counterHalf) {
s += hist2.at(i);
}
dest.at(2) = i-1;
}
// normalize to 0..1
dest.divide(255);
return true;
};