more writing stuff

This commit is contained in:
Joseph Redmon 2015-09-22 17:34:48 -07:00
parent 2a1025b6f0
commit a9e16d914a
3 changed files with 16 additions and 0 deletions

View File

@ -494,6 +494,16 @@ image grayscale_image(image im)
return gray;
}
image threshold_image(image im, float thresh)
{
int i;
image t = make_image(im.w, im.h, im.c);
for(i = 0; i < im.w*im.h*im.c; ++i){
t.data[i] = im.data[i]>0 ? 1 : 0;
}
return t;
}
image blend_image(image fore, image back, float alpha)
{
assert(fore.w == back.w && fore.h == back.h && fore.c == back.c);

View File

@ -35,7 +35,9 @@ void saturate_exposure_image(image im, float sat, float exposure);
void hsv_to_rgb(image im);
void rgbgr_image(image im);
void constrain_image(image im);
image grayscale_image(image im);
image threshold_image(image im, float thresh);
image collapse_image_layers(image source, int border);
image collapse_images_horz(image *ims, int n);

View File

@ -102,6 +102,10 @@ void test_writing(char *cfgfile, char *weightfile, char *outfile)
printf("%s: Predicted in %f seconds.\n", filename, sec(clock()-time));
image pred = get_network_image(net);
image t = threshold_image(pred, .2);
free_image(pred);
pred = t;
if (outfile) {
printf("Save image as %s.png (shape: %d %d)\n", outfile, pred.w, pred.h);
save_image(pred, outfile);