本文整理汇总了C++中save_image函数的典型用法代码示例。如果您正苦于以下问题:C++ save_image函数的具体用法?C++ save_image怎么用?C++ save_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_image函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inter_dcgan
void inter_dcgan(char *cfgfile, char *weightfile)
{
network *net = load_network(cfgfile, weightfile, 0);
set_batch_network(net, 1);
srand(2222222);
clock_t time;
char buff[256];
char *input = buff;
int i, imlayer = 0;
for (i = 0; i < net->n; ++i) {
if (net->layers[i].out_c == 3) {
imlayer = i;
printf("%d\n", i);
break;
}
}
image start = random_unit_vector_image(net->w, net->h, net->c);
image end = random_unit_vector_image(net->w, net->h, net->c);
image im = make_image(net->w, net->h, net->c);
image orig = copy_image(start);
int c = 0;
int count = 0;
int max_count = 15;
while(1){
++c;
if(count == max_count){
count = 0;
free_image(start);
start = end;
end = random_unit_vector_image(net->w, net->h, net->c);
if(c > 300){
end = orig;
}
if(c>300 + max_count) return;
}
++count;
slerp(start.data, end.data, (float)count / max_count, im.w*im.h*im.c, im.data);
float *X = im.data;
time=clock();
network_predict(net, X);
image out = get_network_image_layer(net, imlayer);
//yuv_to_rgb(out);
normalize_image(out);
printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
//char buff[256];
sprintf(buff, "out%05d", c);
save_image(out, "out");
save_image(out, buff);
show_image(out, "out", 0);
}
}
示例2: show_images
void show_images(image *ims, int n, char *window)
{
image m = collapse_images_vert(ims, n);
save_image(m, window);
show_image(m, window);
free_image(m);
}
示例3: main
int main(int args, char ** argv) {
misc::process_args(args, argv);
load_image(file_name[0], left_layer.rgb, left_layer.H, left_layer.W);
load_image(file_name[1], right_layer.rgb, right_layer.H, right_layer.W);
timer.reset();
left.init(left_layer); right.init(right_layer);
//misc::median_filter_rgb(left.rgb, left.H, left.W, 1);
//misc::median_filter_rgb(right.rgb, right.H, right.W, 1);
if (use_lab) {
left_layer.computeLab();
// misc::median_filter_rgb(left.lab, left.H, left.W, 1);
}
left.buildTree(use_lab);
left_layer.computeGradient();
right_layer.computeGradient();
// next part : compute disparity
left.initDisparity();
updateTable(255 * 0.1);
// timer.check("build forest");
left.stereoMatch(right, 1, max_disparity, use_lab);
misc::median_filter(left.disparity, left.H, left.W); //TODO: why radius = 2, not 3 as dp
timer.check("all");
//save
save_image(file_name[2], left.disparity, left.H, left.W, scale);
//save_image(file_name[3], right.disparity, right.H, right.W, scale);
return 0;
}
示例4: image_get
void
image_get()
{
int i, t, index;
char *filename;
for (t = 0; t < IMAGE_QUERY_TURN; t++) {
printf("%d .. ", IMAGE_QUERY_TURN - t);
fflush(stdout);
for (i = 0; i < video.buffer.req.count; i++) {
buffer_dequeue(i);
buffer_enqueue(i);
}
}
printf("%d ..\n", IMAGE_QUERY_TURN - t);
fflush(stdout);
index = 0;
buffer_dequeue(index);
update_image_pixels(index);
filename = get_file_name("swc", "jpeg");
save_image(filename);
printf("%s saved.\n", filename);
free(filename);
buffer_enqueue(index);
}
示例5: main
int main(int args, char ** argv) {
misc::process_args(args, argv);
load_image(file_name[0], left_pyramid[0].rgb, left_pyramid[0].H, left_pyramid[0].W);
load_image(file_name[1], right_pyramid[0].rgb, right_pyramid[0].H, right_pyramid[0].W);
if (left_pyramid[0].H != right_pyramid[0].H || left_pyramid[0].W != right_pyramid[0].W) {
printf("The size of two pictures differ!! quit....");
return 0;
}
if (left_pyramid[0].H >= MAX_HEIGHT || right_pyramid[0].W >= MAX_WIDTH) {
printf("Input : %d x %d, program : %d %d\n", left_pyramid[0].H, left[0].W, MAX_HEIGHT, MAX_WIDTH);
puts("Image too big. change settings.hpp and re-compile.");
return 0;
}
timer.reset();
if (use_lab) {
left_pyramid[0].computeLab();
right_pyramid[0].computeLab();
}
for (int i = 0; i + 1 < levels; ++i) {
left_pyramid[i+1].shrinkPicture(left_pyramid[i+1].rgb, left_pyramid[i].rgb, left_pyramid[i].H, left_pyramid[i].W);
right_pyramid[i+1].shrinkPicture(right_pyramid[i+1].rgb, right_pyramid[i].rgb, right_pyramid[i].H, right_pyramid[i].W);
if (use_lab) {
left_pyramid[i+1].shrinkPicture(left_pyramid[i+1].lab, left_pyramid[i].lab, left_pyramid[i].H, left_pyramid[i].W);
right_pyramid[i+1].shrinkPicture(right_pyramid[i+1].lab, right_pyramid[i].lab, right_pyramid[i].H, right_pyramid[i].W);
}
}
for (int lvl = levels - 1; lvl >= 0; -- lvl) {
int idx = lvl % OBJ_NUM;
left[idx].init(left_pyramid[lvl]);
right[idx].init(right_pyramid[lvl]);
if (lvl == levels - 1) {
left[idx].noPrediction(max_disparity / (1 << lvl));
} else {
DP::getSupportProb(left[idx].rgb, right[idx].rgb,
left[idx].H, left[idx].W, max_disparity / (1 << lvl));
DP::getProbMatrix(lvl, max_disparity / (1 << (lvl + 1)), max_disparity / (1 << lvl), dataset);
DP::getInterval(pixel_intv_threshold * (1 << lvl)/*, tot_threshold*/);
left[idx].readPrediction(left[(lvl + 1)%OBJ_NUM].disparity);
// left[idx].intersectInterval(left[(lvl + 1) % OBJ_NUM]);
}
// Now use the INTERVAL to find the new disparities.
left_pyramid[lvl].computeGradient();
right_pyramid[lvl].computeGradient();
left[idx].buildForest(tree_intv_threshold, use_lab);
left[idx].noPrediction(max_disparity / (1 << lvl));
left[idx].initDisparity();
updateTable(255 * 0.1);
left[idx].stereoMatch(right[idx], 1, use_lab);
misc::median_filter(left[idx].disparity, left[idx].H, left[idx].W, 3);
// save_image(layername[lvl][0], left[idx].disparity, left[idx].H, left[idx].W, scale * (1 << lvl));
} // end of layer iteration.
timer.check("all");
save_image(file_name[2], left[0].disparity, left[0].H, left[0].W, scale);
return 0;
}
示例6: toDarkImage
void Darknet::yoloImage(const QString &filename, float thresh)
{
const Mat ori = OpenCV::loadImage(getAbs(filename), -1);
Mat img;
cv::resize(ori, img, cv::Size(priv->net.w, priv->net.h));
image im = toDarkImage(img);
//image im = load_image_color((char *)qPrintable(getAbs(filename)), 0, 0);
//image sized = resize_image(im, priv->net.w, priv->net.h);
//float *X = sized.data;
float *X = im.data;
float *predictions = network_predict(priv->net, X);
float nms=.5;
const detection_layer l = priv->l;
convert_yolo_detections(predictions, l.classes, l.n, l.sqrt, l.side, 1, 1, thresh, priv->probs, priv->boxes, 0);
if (nms) do_nms_sort(priv->boxes, priv->probs, l.side*l.side*l.n, l.classes, nms);
draw_detections(im, l.side*l.side*l.n, thresh, priv->boxes, priv->probs, voc_names, 0, 20);
show_image(im, "predictions");
save_image(im, "predictions");
//show_image(sized, "resized");
free_image(im);
//free_image(sized);
}
示例7: make_preview
static void
make_preview (void)
{
destroy_preview ();
if (jsvals.preview)
{
gchar *tn = gimp_temp_name ("jpeg");
if (! undo_touched)
{
/* we freeze undo saving so that we can avoid sucking up
* tile cache with our unneeded preview steps. */
gimp_image_undo_freeze (preview_image_ID);
undo_touched = TRUE;
}
save_image (tn,
preview_image_ID,
drawable_ID_global,
orig_image_ID_global,
TRUE, NULL);
if (display_ID == -1)
display_ID = gimp_display_new (preview_image_ID);
}
else
{
gtk_label_set_text (GTK_LABEL (preview_size), _("File size: unknown"));
gimp_displays_flush ();
}
}
示例8: draw_loop
void draw_loop(const char *dir, int start_image_num, int num_images)
{
int key, i;
IplImage *img;
CvSize size = { IMAGE_WIDTH, IMAGE_HEIGHT };
img = cvCreateImage(size, IPL_DEPTH_8U, 1); //3);
if (!img)
return;
for (i = start_image_num; i < start_image_num + num_images; i++) {
draw_shapes(img);
cvShowImage("shapegen", img);
save_image(dir, img, i);
if (dir)
key = 0xff & cvWaitKey(500);
else
key = 0xff & cvWaitKey(0);
if (key == ESCAPE_KEY)
break;
}
cvReleaseImage(&img);
}
示例9: create_image_base
static surface
create_image_base(const std::string& filename)
{
surface result = SDL_CreateRGBSurface(
SDL_SWSURFACE
, 1024
, 1024
, 32
, 0xFF0000
, 0xFF00
, 0xFF
, 0);
surface_lock lock(result);
Uint32 *pixels = lock.pixels();
for(Uint32 r = 0; r < 256; r += 4) {
for(Uint32 g = 0; g < 256; g += 2) {
for(Uint32 b = 0; b < 256; b += 2, ++pixels) {
*pixels = (0xFF << 24) | (r << 16) | (g << 8) | b;
}
}
}
save_image(result, filename);
return result;
}
示例10: mkimg
void mkimg(char *cfgfile, char *weightfile, int h, int w, int num, char *prefix)
{
network *net = load_network(cfgfile, weightfile, 0);
image *ims = get_weights(net->layers[0]);
int n = net->layers[0].n;
int z;
for(z = 0; z < num; ++z){
image im = make_image(h, w, 3);
fill_image(im, .5);
int i;
for(i = 0; i < 100; ++i){
image r = copy_image(ims[rand()%n]);
rotate_image_cw(r, rand()%4);
random_distort_image(r, 1, 1.5, 1.5);
int dx = rand()%(w-r.w);
int dy = rand()%(h-r.h);
ghost_image(r, im, dx, dy);
free_image(r);
}
char buff[256];
sprintf(buff, "%s/gen_%d", prefix, z);
save_image(im, buff);
free_image(im);
}
free_network(net);
}
示例11: test_detector
void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filename, float thresh, float hier_thresh)
{
int show_flag = 1;
list *options = read_data_cfg(datacfg);
char *name_list = option_find_str(options, "names", "data/names.list");
char **names = get_labels(name_list);
image **alphabet = load_alphabet();
network net = parse_network_cfg(cfgfile);
if(weightfile){
load_weights(&net, weightfile);
}
set_batch_network(&net, 1);
srand(2222222);
clock_t time;
char buff[256];
char *input = buff;
int j;
float nms=.4;
while(1){
if(filename){
strncpy(input, filename, 256);
} else {
printf("Enter Image Path: ");
fflush(stdout);
input = fgets(input, 256, stdin);
if(!input) return;
strtok(input, "\n");
}
image im = load_image_color(input,0,0);
image sized = resize_image(im, net.w, net.h);
layer l = net.layers[net.n-1];
box *boxes = calloc(l.w*l.h*l.n, sizeof(box));
float **probs = calloc(l.w*l.h*l.n, sizeof(float *));
for(j = 0; j < l.w*l.h*l.n; ++j) probs[j] = calloc(l.classes + 1, sizeof(float *));
float *X = sized.data;
time=clock();
network_predict(net, X);
printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
get_region_boxes(l, 1, 1, thresh, probs, boxes, 0, 0, hier_thresh);
if (l.softmax_tree && nms) do_nms_obj(boxes, probs, l.w*l.h*l.n, l.classes, nms);
else if (nms) do_nms_sort(boxes, probs, l.w*l.h*l.n, l.classes, nms);
draw_detections(im, l.w*l.h*l.n, thresh, boxes, probs, names, alphabet, l.classes, show_flag);
save_image(im, "predictions");
show_image(im, "predictions");
free_image(im);
free_image(sized);
free(boxes);
free_ptrs((void **)probs, l.w*l.h*l.n);
#ifdef OPENCV
cvWaitKey(0);
cvDestroyAllWindows();
#endif
if (filename) break;
}
}
示例12: save_image
void save_image(Image::ConstRefArg image,
std::string file_path, std::string format_name,
Logger* logger, FileFormat::ProgressTracker* tracker,
FileFormat::Registry::ConstRefArg r)
{
save_image(image, *make_file_output_stream(file_path),
file_path, format_name, logger, tracker, r);
}
示例13: save_image
/***********************************************************************//**
* @brief Save FITS image
*
* Saves the image into the FITS file.
***************************************************************************/
void GFitsImage::data_save(void)
{
// Save image
save_image(type(), pixels());
// Return
return;
}
示例14: main
int main(void) {
Image image;
image.width = DIM;
image.height = DIM;
mandel(-1.25, -2, 1.25, 0.5, &image);
save_image("mandelbrot.pnm", &image);
return EXIT_SUCCESS;
}
示例15: test_layer_reverse
int test_layer_reverse()
{
// Blog: http://blog.csdn.net/fengbingchun/article/details/77160872
#ifdef __linux__
std::string image_name{ "test_data/images/lena.png" };
#else
std::string image_name{ "E:/GitCode/CUDA_Test/test_data/images/lena.png" };
#endif
cv::Mat matSrc = cv::imread(image_name);
CHECK(matSrc.data);
cv::cvtColor(matSrc, matSrc, CV_BGR2GRAY);
const int width{ 1511 }, height{ 1473 };
const auto length = width * height;
cv::resize(matSrc, matSrc, cv::Size(width, height));
cv::Mat matTmp1;
matSrc.convertTo(matTmp1, CV_32FC1);
float elapsed_time1{ 0.f }, elapsed_time2{ 0.f }; // milliseconds
const std::vector<int> vec{ 5, 7};
std::unique_ptr<float[]> dst1(new float[length]), dst2(new float[length]);
std::for_each(dst1.get(), dst1.get() + length, [](float& n) {n = 0.f; });
std::for_each(dst2.get(), dst2.get() + length, [](float& n) {n = 0.f; });
int ret = layer_reverse_cpu((float*)matTmp1.data, dst1.get(), length, vec, &elapsed_time1);
if (ret != 0) PRINT_ERROR_INFO(image_reverse_cpu);
ret = layer_reverse_gpu((float*)matTmp1.data, dst2.get(), length, vec, &elapsed_time2);
if (ret != 0) PRINT_ERROR_INFO(image_reverse_gpu);
compare_result(dst1.get(), dst2.get(), length);
cv::Mat matTmp2(height, width, CV_32FC1, dst2.get()), matDst;
matTmp2.convertTo(matDst, CV_8UC1);
#ifdef __linux__
save_image(matSrc, matDst, 400, 200, "test_data/images/image_reverse.png");
#else
save_image(matSrc, matDst, 400, 200, "E:/GitCode/CUDA_Test/test_data/images/image_reverse.png");
#endif
fprintf(stderr, "test layer reverse: cpu run time: %f ms, gpu run time: %f ms\n", elapsed_time1, elapsed_time2);
return 0;
}