mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
more writing stuff
This commit is contained in:
10
src/image.c
10
src/image.c
@ -494,6 +494,16 @@ image grayscale_image(image im)
|
|||||||
return gray;
|
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)
|
image blend_image(image fore, image back, float alpha)
|
||||||
{
|
{
|
||||||
assert(fore.w == back.w && fore.h == back.h && fore.c == back.c);
|
assert(fore.w == back.w && fore.h == back.h && fore.c == back.c);
|
||||||
|
@ -35,7 +35,9 @@ void saturate_exposure_image(image im, float sat, float exposure);
|
|||||||
void hsv_to_rgb(image im);
|
void hsv_to_rgb(image im);
|
||||||
void rgbgr_image(image im);
|
void rgbgr_image(image im);
|
||||||
void constrain_image(image im);
|
void constrain_image(image im);
|
||||||
|
|
||||||
image grayscale_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_image_layers(image source, int border);
|
||||||
image collapse_images_horz(image *ims, int n);
|
image collapse_images_horz(image *ims, int n);
|
||||||
|
@ -102,6 +102,10 @@ void test_writing(char *cfgfile, char *weightfile, char *outfile)
|
|||||||
printf("%s: Predicted in %f seconds.\n", filename, sec(clock()-time));
|
printf("%s: Predicted in %f seconds.\n", filename, sec(clock()-time));
|
||||||
image pred = get_network_image(net);
|
image pred = get_network_image(net);
|
||||||
|
|
||||||
|
image t = threshold_image(pred, .2);
|
||||||
|
free_image(pred);
|
||||||
|
pred = t;
|
||||||
|
|
||||||
if (outfile) {
|
if (outfile) {
|
||||||
printf("Save image as %s.png (shape: %d %d)\n", outfile, pred.w, pred.h);
|
printf("Save image as %s.png (shape: %d %d)\n", outfile, pred.w, pred.h);
|
||||||
save_image(pred, outfile);
|
save_image(pred, outfile);
|
||||||
|
Reference in New Issue
Block a user