本文整理汇总了C++中ofImage::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ ofImage::resize方法的具体用法?C++ ofImage::resize怎么用?C++ ofImage::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofImage
的用法示例。
在下文中一共展示了ofImage::resize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMasked
void testApp::makeMasked(ofImage mask, ofImage toBeMasked){
// if you want blurrier outlines, try smaller numbers, fewer cycles than blurring.
// mask.resize(40,30);
mask.resize(80,60);
mask.resize(WIDTH,HEIGHT);
makeMe.setFromPixels(toBeMasked.getPixels(),WIDTH,HEIGHT,OF_IMAGE_COLOR);
//then draw a quad for the top layer using our composite shader to set the alpha
maskShader.begin();
//our shader uses two textures, the top layer and the alpha
//we can load two textures into a shader using the multi texture coordinate extensions
glActiveTexture(GL_TEXTURE0_ARB);
makeMe.getTextureReference().bind();
glActiveTexture(GL_TEXTURE1_ARB);
mask.getTextureReference().bind();
//draw a quad the size of the frame
glBegin(GL_QUADS);
glMultiTexCoord2d(GL_TEXTURE0_ARB, 0, 0);
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, 0);
glVertex2f( 0, 0);
glMultiTexCoord2d(GL_TEXTURE0_ARB, WIDTH, 0);
glMultiTexCoord2d(GL_TEXTURE1_ARB, WIDTH, 0);
glVertex2f( ofGetWidth(), 0);
glMultiTexCoord2d(GL_TEXTURE0_ARB, WIDTH, HEIGHT);
glMultiTexCoord2d(GL_TEXTURE1_ARB, WIDTH, HEIGHT);
glVertex2f( ofGetWidth(), ofGetHeight());
glMultiTexCoord2d(GL_TEXTURE0_ARB, 0, HEIGHT);
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, HEIGHT);
glVertex2f( 0, ofGetHeight());
glEnd();
//deactive and clean up
glActiveTexture(GL_TEXTURE1_ARB);
mask.getTextureReference().unbind();
//mask.unbind();
glActiveTexture(GL_TEXTURE0_ARB);
makeMe.getTextureReference().unbind();
maskShader.end();
}
示例2: addFrame
void ofxQTVideoSaver::addFrame(ofImage newImg){
// downscale if dims dont match
if(newImg.width != vidOutputWidth || newImg.height != vidOutputHeight){
// resize image before output
newImg.resize(vidOutputWidth, vidOutputHeight);
}
video.addFrame(newImg.getPixels(), 1.0f / vidFrameRate);
numRecordedFrames++;
if(numRecordedFrames % videoFrameLength == 0 ) {
numRecordedFrames = 1;
string vidName = vidDir + "/"+ vidNamePrefix + ofToString(curVideoNum) +".mov";
printf("save curVideoNum \n");
// Save the movie to disk
video.finishMovie();
video.setup(vidOutputWidth,vidOutputHeight,vidName);
curVideoNum++;
if(curVideoNum > maxVideos) {
/* clean up code should start to run here*/
/* this class will infinitly create mov files so you might want to delete some
after a few have been made
*/
};
}
}
示例3: makeThumb
void makeThumb(string vidPath, string thumb){
ofVideoPlayer tmp;
tmp.loadMovie(vidPath);
tmp.play();
tmp.setPosition(0.3);
ofImage img;
img.setFromPixels( tmp.getPixelsRef() );
img.resize(120, 120.0f * (img.getHeight() / img.getWidth()) );
img.saveImage(thumb);
}
示例4: pixelManipulate
//--------------------------------------------------------------
ofMesh testApp::pixelManipulate(ofImage imageA, ofMesh meshA, float intensityThreshold, float sketchDepth){
imageA.resize(200, 200);
//create mesh with points as the primitive
//meshA.setMode(OF_PRIMITIVE_POINTS);
//create a mesh with lines
meshA.setMode(OF_PRIMITIVE_LINE_LOOP);
//meshA.setMode(OF_PRIMITIVE_LINE_STRIP);
int w = imageA.getWidth();
int h = imageA.getHeight();
//loop through each pixel in the image using image width & height
for (int x=0; x<w; x++){
for(int y=0; y<h; y++){
//create the color object at that pixel
//ofColor c = imageA.getColor(x, y);
ofColor c = imageA.getColor(x, y);
//check the intensity of the pixel's color
float intensity = c.getLightness();
//if the intensity exceeds the threshold, create a vertex at the location of the pixel
//& color it with the pixel's color
if (intensity >= intensityThreshold){
//pushes brighter colors in the positive z direction
//pushes whiter colors in the negative z direction
float saturation = c.getSaturation();
float z = ofMap(saturation, 0, 255, -sketchDepth, sketchDepth);
//the image is now 1/4 the size of the OF window, so multiply
//the pixel location by 4 so that the mesh covers the OF window
ofVec3f pos(5*x, 4*y, z);
meshA.addVertex(pos);
meshA.addColor(c);
}
}
}
return meshA;
}
示例5: loadImage
void loadImage(string filePath)
{
vector<string>hierarchy = ofSplitString(filePath, "/");
if (hierarchy.size() > 1)
cur_file = hierarchy.back();
else
cur_file = filePath;
img1.loadImage(filePath);
img1.resize(w, h);
img1.setImageType(OF_IMAGE_GRAYSCALE);
synthImage();
}
示例6: saveScanImg
void scanner_faces::saveScanImg(ofImage &imgScan, int nPers, int nImg) {
string nmImgScan = "images/scan/";
nmImgScan += ofToString(ofGetYear())+ofToString(ofGetMonth(),2,'0')+ofToString(ofGetDay(),2,'0')+
ofToString(ofGetHours(),2,'0')+ofToString(ofGetMinutes(),2,'0');
nmImgScan += "_cara_"+ofToString(nPers,3,'0')+"_"+ofToString(nImg,2,'0')+".png";
ofLogNotice("grabar:_"+nmImgScan);
// redimensionar
imgScan.resize(WSCAN, HSCAN);
imgScan.saveImage(nmImgScan);
snd_click.play();
}
示例7: setup
//--------------------------------------------------------------
void ofApp::setup(){
arraySounds = new ofSoundPlayer[numberOfSounds];
for(int i=0;i<numberOfSounds;++i){
arraySounds[i].loadSound("sounds/TheWhole"+ofToString(i+1)+".mp3");
arraySounds[i].setVolume(0.9f);
}
currentSoundIndex = 0;
ofSetWindowShape(1000, 1000);
image.loadImage("output_croped.png");
image.resize(700, 600);
zoomFactor = 2.0;
radius = 180;
imgPos.x = 100;
imgPos.y = 30;
}
示例8: Rectify_Image
void ofxCorrectPerspective::Rectify_Image(ofImage & my_image,double focal_length,double sensor_width, double & alpha, double & beta){
resize_image=1; //To Enable or Disable Resize
//Rescale Image to be Max in 1000px
if (resize_image && max(my_image.width,my_image.height)>1000)
{
float s=float(1000)/max(my_image.width,my_image.height);
my_image.resize(floor(my_image.width*s),floor(my_image.height*s));
}
float f=focal_length*(float)max(my_image.width,my_image.height)/sensor_width;
K.set(f,0.0,0.0,0.0,f,0.0,0.0,0.0,1.0);
center.set(double(my_image.width)/2.0,double(my_image.height)/2.0);
if (talk) cout << K;
my_img_gray=my_image;
my_img_gray.setImageType(OF_IMAGE_GRAYSCALE);
//Converting Image to Image Double//
image_double dub_image;
ntuple_list lsd_out;
unsigned int w=my_img_gray.width;
unsigned int h=my_img_gray.height;
unsigned char * imgP=my_img_gray.getPixels();
// LSD parameters start
double scale = 0.8; // Scale the image by Gaussian filter to 'scale'.
double sigma_scale = 0.6; // Sigma for Gaussian filter is computed as sigma = sigma_scale/scale.
double quant = 2.0; // Bound to the quantization error on the gradient norm.
double ang_th = 22.5; // Gradient angle tolerance in degrees.
double eps = 0.0; // Detection threshold, -log10(NFA).
double density_th = 0.7; // Minimal density of region points in rectangle.
int n_bins = 1024; // Number of bins in pseudo-ordering of gradient modulus.
double max_grad = 255.0; // Gradient modulus in the highest bin. The default value corresponds to the highest
// gradient modulus on images with gray levels in [0,255].
// LSD parameters end
bool verbose=0;
dub_image = new_image_double(w,h);
double px=0;
cout << "\n--------\nInput data being written to image buffer \n";
for(int j=0;j<(w*h);j++){
px=imgP[j];
dub_image->data[j] = px;
if (verbose){
cout << " " << dub_image->data[j];
}
}
// Call LSD //
lsd_out = LineSegmentDetection( dub_image, scale, sigma_scale, quant, ang_th, eps,
density_th, n_bins, max_grad, NULL );
cout << "LSD has done it's thing!\n";
if (talk) cout << "Number of Lines: "<< lsd_out->size << "Number of Dimensions: " << lsd_out->dim << "\n";
if (verbose)
{
cout << "LSD Values: " << lsd_out->values[0] << " " << lsd_out->values[1] <<" " << lsd_out->values[2] <<" " << lsd_out->values[3] <<" " << lsd_out->values[4] <<" " << lsd_out->values[5] << "\n";
}
//Sorting in (Value, Index) pairs
//http://stackoverflow.com/questions/1577475/c-sorting-and-keeping-track-of-indexes
std::vector<mypair> line_lengths;
double sqd_distance;
mesh.setMode(OF_PRIMITIVE_LINES);
mesh.enableColors();
ofVec3f first(0.0,0.0,0.0);
ofVec3f second(0.0,0.0,0.0);
double x1,x2,y1,y2;
for(int j=0;j<(lsd_out->size*lsd_out->dim);j=j+5){
x1=lsd_out->values[j];
y1=lsd_out->values[j+1];
x2=lsd_out->values[j+2];
y2=lsd_out->values[j+3];
sqd_distance=(x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
line_lengths.push_back(make_pair(sqd_distance,j));
//To Draw as Primitive Lines//
/*first.set(x2,y2,0.0);
second.set(x1,y1,0.0);
mesh.addVertex(first);
mesh.addColor(ofFloatColor(1.0, 0.0, 0.0));
mesh.addVertex(second);
mesh.addColor(ofFloatColor(1.0, 0.0, 0.0));*/
//Lines Added, will be drawn//
}
sort(line_lengths.begin(),line_lengths.end());
reverse(line_lengths.begin(), line_lengths.end());
if (talk) cout << line_lengths[0].first << " " << line_lengths[0].second << " " << line_lengths[1].first << " " << line_lengths[1].second << "\n";
unsigned int maxlines=700;
unsigned int no_of_lines=min(lsd_out->size,maxlines);
//Store these Lines pairs in a Matrix, in descending order of Distance
cout << "Number of Lines: " << no_of_lines << "\n";
L.resize(4);
//.........这里部分代码省略.........