C++ Boost GIL Library; Issue with converting PNG to JPG - c++

I'm working on a small personal project that converts images from different formats for ML purposes - specifically with multi-threading in mind.
Initially, everything was working smoothly: PNGs were being converted into JPGs as expected. I then added more images to the test batch which resulted in errors.
Apologies if my grammar is off or if I'm missing any info, I'm heavily sleep deprived as I type this lol.
I attempted to add more image types to the boost::gil::any_image keyword, which did help with the majority of the test batch, but I'm now left with 3 files that will not convert.
Code being run: -> int main()
using namespace boost::gil;
any_image<gray1_image_t, gray4_image_t, gray8_image_t, gray16_image_t, gray32_image_t, gray64f_image_t, rgb8_image_t, rgb16_image_t, rgb32_image_t, rgb64f_image_t, rgba8_image_t, rgba16_image_t, rgba32_image_t, rgba64f_image_t> img;
for (int i = 0; i < f_cache_size; i++) {
std::string tmp_png = R"()" + final_cache[i];
read_image(tmp_png, img, png_tag());
container.png_to_jpg(tmp_png, img, 95);
}
-> Convert.cpp
// Converts PNG files into JPG files
void Convert::png_to_jpg(std::string fileName, boost::gil::any_image<boost::gil::gray1_image_t, boost::gil::gray4_image_t, boost::gil::gray8_image_t, boost::gil::gray16_image_t, boost::gil::gray32_image_t, boost::gil::gray64f_image_t, boost::gil::rgb8_image_t, boost::gil::rgb16_image_t, boost::gil::rgb32_image_t, boost::gil::rgb64f_image_t, boost::gil::rgba8_image_t, boost::gil::rgba16_image_t, boost::gil::rgba32_image_t, boost::gil::rgba64f_image_t> image, int quality)
{
using namespace boost::gil;
std::string jpg = R"(.jpg)";
std::string png = R"(.png)";
fileName = remove_postfix_from_string(fileName, png, jpg);
write_view(fileName, view(image), image_write_info<jpeg_tag>(quality));
}
Error code after attempting to run the program:
terminate called after throwing an instance of 'std::ios_base::failure[abi:cxx11]'
what(): dynamic_io: unsupported view type for the given file format: iostream error
Aborted (core dumped)
Extra information on 3 different image files:
Image:
Filename: rebarchi_ - pog.png
Permissions: rw-r--r--
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 898x677+0+0
Units: Undefined
Colorspace: sRGB
Type: TrueColorAlpha
Endianness: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 1-bit
Channel statistics:
Pixels: 607946
Red:
min: 0 (0)
max: 255 (1)
mean: 230.031 (0.902081)
median: 254 (0.996078)
standard deviation: 53.3536 (0.20923)
kurtosis: 4.84342
skewness: -2.35946
entropy: 0.430811
Green:
min: 0 (0)
max: 255 (1)
mean: 220.531 (0.864827)
median: 251 (0.984314)
standard deviation: 60.4584 (0.237092)
kurtosis: 2.50953
skewness: -1.91354
entropy: 0.461063
Blue:
min: 0 (0)
max: 255 (1)
mean: 200.472 (0.786166)
median: 233 (0.913725)
standard deviation: 60.5139 (0.237309)
kurtosis: 1.31362
skewness: -1.62729
entropy: 0.581842
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
median: 255 (1)
standard deviation: 0 (0)
kurtosis: 1.6384e+52
skewness: 9.375e+35
entropy: 0
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 226.509 (0.888269)
median: 248.25 (0.973529)
standard deviation: 43.5815 (0.170908)
kurtosis: 4.43874
skewness: -2.3037
entropy: 0.368429
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 898x677+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Profiles:
Profile-icc: 672 bytes
Properties:
date:create: 2023-01-23T21:48:17+00:00
date:modify: 2023-01-23T21:48:17+00:00
date:timestamp: 2023-01-23T22:41:00+00:00
icc:copyright: Public Domain
icc:description: GIMP built-in sRGB
icc:manufacturer: GIMP
icc:model: sRGB
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:iCCP: chunk was found
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 6
png:IHDR.color_type: 6 (RGBA)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 898, 677
png:text: 8 tEXt/zTXt/iTXt chunks were found
png:text-encoded profiles: 1 were found
signature: 4c66ed2e90b6170ec6aa73f893b89d8007d0df621c15f78aab89891fe086a942
Artifacts:
verbose: true
Tainted: False
Filesize: 885759B
Number pixels: 607946
Pixel cache type: Memory
Pixels per second: 46.257MP
User time: 0.020u
Elapsed time: 0:01.013
Version: ImageMagick 7.1.0-58 Q16-HDRI x86_64 20802 https://imagemagick.org
Image:
Filename: insane.png
Permissions: rwxr-xr-x
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 753x770+0+0
Resolution: 28.34x28.34
Print size: 26.5702x27.1701
Units: PixelsPerCentimeter
Colorspace: sRGB
Type: TrueColorAlpha
Endianness: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 8-bit
Channel statistics:
Pixels: 579810
Red:
min: 0 (0)
max: 255 (1)
mean: 73.6133 (0.28868)
median: 0 (0)
standard deviation: 100.617 (0.394577)
kurtosis: -0.917795
skewness: 0.925
entropy: 0.381909
Green:
min: 0 (0)
max: 255 (1)
mean: 66.3444 (0.260174)
median: 0 (0)
standard deviation: 91.5125 (0.358873)
kurtosis: -0.879259
skewness: 0.938695
entropy: 0.386062
Blue:
min: 0 (0)
max: 255 (1)
mean: 62.6174 (0.245558)
median: 0 (0)
standard deviation: 83.5006 (0.327453)
kurtosis: -0.967664
skewness: 0.854211
entropy: 0.380587
Alpha:
min: 0 (0)
max: 255 (1)
mean: 113.83 (0.446393)
median: 0 (0)
standard deviation: 126.362 (0.495537)
kurtosis: -1.94916
skewness: 0.21525
entropy: 0.152762
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 79.1013 (0.310201)
median: 0 (0)
standard deviation: 100.498 (0.39411)
kurtosis: -1.19736
skewness: 0.773146
entropy: 0.32533
Alpha: none #00000000
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 753x770+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2023-01-23T20:57:57+00:00
date:modify: 2023-01-23T20:57:57+00:00
date:timestamp: 2023-01-23T20:59:30+00:00
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 6
png:IHDR.color_type: 6 (RGBA)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 753, 770
png:pHYs: x_res=2834, y_res=2834, units=1
signature: d2aab82c02f789a4830019216e2ec4946d2535fc211fc003b7737831221c6de2
Artifacts:
verbose: true
Tainted: False
Filesize: 204968B
Number pixels: 579810
Pixel cache type: Memory
Pixels per second: 62.2394MP
User time: 0.020u
Elapsed time: 0:01.009
Version: ImageMagick 7.1.0-58 Q16-HDRI x86_64 20802 https://imagemagick.org
[blink#MythOS TEST]$ identify -verbose insane.png
Image:
Filename: insane.png
Permissions: rw-r--r--
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 753x770+0+0
Resolution: 28.34x28.34
Print size: 26.5702x27.1701
Units: PixelsPerCentimeter
Colorspace: sRGB
Type: TrueColorAlpha
Endianness: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 8-bit
Channel statistics:
Pixels: 579810
Red:
min: 0 (0)
max: 255 (1)
mean: 73.6133 (0.28868)
median: 0 (0)
standard deviation: 100.617 (0.394577)
kurtosis: -0.917795
skewness: 0.925
entropy: 0.381909
Green:
min: 0 (0)
max: 255 (1)
mean: 66.3444 (0.260174)
median: 0 (0)
standard deviation: 91.5125 (0.358873)
kurtosis: -0.879259
skewness: 0.938695
entropy: 0.386062
Blue:
min: 0 (0)
max: 255 (1)
mean: 62.6174 (0.245558)
median: 0 (0)
standard deviation: 83.5006 (0.327453)
kurtosis: -0.967664
skewness: 0.854211
entropy: 0.380587
Alpha:
min: 0 (0)
max: 255 (1)
mean: 113.83 (0.446393)
median: 0 (0)
standard deviation: 126.362 (0.495537)
kurtosis: -1.94916
skewness: 0.21525
entropy: 0.152762
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 79.1013 (0.310201)
median: 0 (0)
standard deviation: 100.498 (0.39411)
kurtosis: -1.19736
skewness: 0.773146
entropy: 0.32533
Alpha: none #00000000
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 753x770+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2023-01-23T21:48:17+00:00
date:modify: 2023-01-23T21:48:17+00:00
date:timestamp: 2023-01-23T21:48:27+00:00
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 6
png:IHDR.color_type: 6 (RGBA)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 753, 770
png:pHYs: x_res=2834, y_res=2834, units=1
png:text: 3 tEXt/zTXt/iTXt chunks were found
signature: d2aab82c02f789a4830019216e2ec4946d2535fc211fc003b7737831221c6de2
Artifacts:
verbose: true
Tainted: False
Filesize: 204437B
Number pixels: 579810
Pixel cache type: Memory
Pixels per second: 62.4627MP
User time: 0.020u
Elapsed time: 0:01.009
Version: ImageMagick 7.1.0-58 Q16-HDRI x86_64 20802 https://imagemagick.org
Image:
Filename: smooth_brain.png
Permissions: rwxr-xr-x
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 557x556+0+0
Resolution: 37.79x37.79
Print size: 14.7393x14.7129
Units: PixelsPerCentimeter
Colorspace: sRGB
Type: TrueColorAlpha
Endianness: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 1-bit
Channel statistics:
Pixels: 309692
Red:
min: 0 (0)
max: 255 (1)
mean: 186.136 (0.729945)
median: 220 (0.862745)
standard deviation: 68.4489 (0.268427)
kurtosis: 2.4105
skewness: -1.97795
entropy: 0.68527
Green:
min: 0 (0)
max: 236 (0.92549)
mean: 176.377 (0.691674)
median: 209 (0.819608)
standard deviation: 71.0393 (0.278586)
kurtosis: 1.32263
skewness: -1.63417
entropy: 0.688323
Blue:
min: 0 (0)
max: 255 (1)
mean: 181.988 (0.713678)
median: 211 (0.827451)
standard deviation: 65.9658 (0.258689)
kurtosis: 2.31119
skewness: -1.87115
entropy: 0.696014
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
median: 255 (1)
standard deviation: 0 (0)
kurtosis: 1.6384e+52
skewness: 9.375e+35
entropy: 0
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 199.875 (0.783824)
median: 223.75 (0.877451)
standard deviation: 51.3635 (0.201425)
kurtosis: 3.02315
skewness: -1.95237
entropy: 0.517402
Rendering intent: Perceptual
Gamma: 0.45455
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 557x556+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2023-01-23T20:57:57+00:00
date:modify: 2023-01-23T20:57:57+00:00
date:timestamp: 2023-01-23T20:58:24+00:00
png:cHRM: chunk was found (see Chromaticity, above)
png:gAMA: gamma=0.45455 (See Gamma, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 6
png:IHDR.color_type: 6 (RGBA)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 557, 556
png:pHYs: x_res=3779, y_res=3779, units=1
png:sRGB: intent=0 (Perceptual Intent)
signature: c5a4758ce0030fa4dcba3c8de843cb8a89157563cd4bc305d7c887301e813ddf
Artifacts:
verbose: true
Tainted: False
Filesize: 225641B
Number pixels: 309692
Pixel cache type: Memory
Pixels per second: 65.1504MP
User time: 0.000u
Elapsed time: 0:01.004
Version: ImageMagick 7.1.0-58 Q16-HDRI x86_64 20802 https://imagemagick.org

Related

How can I read a tiff file with OpenCV in Windows

I installed OpenCV in my Windows OS and successfully configure a correpond Visual Studio project. But when I use imread to read a tiff image file, the Mat object would be empty. If I convert the file to bmp format, the program works. I wonder how can OpenCV do tiff I/O in windows.
My OpenCV version is 2.4.13 and I am using VS 2013.
After running "magick identify", the output is:
Image: TBAL2015032700100902012.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 2502x1505+0+0
Resolution: 300x300
Print size: 8.34x5.01667
Units: PixelsPerInch
Type: TrueColor
Endianess: LSB
Colorspace: sRGB
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Channel statistics:
Pixels: 3765510
Red:
min: 0 (0)
max: 255 (1)
mean: 199.179 (0.781094)
standard deviation: 44.2111 (0.173377)
kurtosis: 9.97873
skewness: -3.17169
entropy: 0.774441
Green:
min: 0 (0)
max: 255 (1)
mean: 204.13 (0.800508)
standard deviation: 41.8485 (0.164112)
kurtosis: 9.24617
skewness: -3.00098
entropy: 0.77394
Blue:
min: 0 (0)
max: 255 (1)
mean: 156.85 (0.615098)
standard deviation: 41.3859 (0.162298)
kurtosis: 1.57158
skewness: -1.13336
entropy: 0.89716
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 186.72 (0.732233)
standard deviation: 47.5017 (0.186281)
kurtosis: 3.30247
skewness: -1.81231
entropy: 0.81518
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 2502x1505+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Orientation: TopLeft
Properties:
comment:
date:create: 2017-12-08T16:15:53+08:00
date:modify: 2015-03-27T10:25:22+08:00
jpeg:sampling-factor: 2x1
signature: 70f8c75014e79eb786765d727ccb564688c3da3c3d5f9f0b4c56f259e2d88625
tiff:alpha: unspecified
tiff:artist: SysAdmin
tiff:document: DN0P46158952 0000000022000000053700000.----!--
tiff:endian: lsb
tiff:make: Eastman Kodak
tiff:model: Kodak Scanner: i1405
tiff:photometric: YCBCR
tiff:rows-per-strip: 1505
tiff:software: KODAK Capture Desktop 1.2
tiff:timestamp: 2015.03.27 10:25:22
Artifacts:
verbose: true
Tainted: False
Filesize: 619460B
Number pixels: 3765510
Pixels per second: 83.6779MB
User time: 0.047u
Elapsed time: 0:01.045
Version: ImageMagick 7.0.7-14 Q16 x64 2017-12-06 http://www.imagemagick.org

how to implement 4-D convolutional kernal

The convolutional kernel in prototxt file needs only setting height and weight of image and the third dimension can be automatically set.
But how do I set 4-D kernel in prototxt file ?
In the figure
the input video is 4-D.
The the work
says the dimension of first convoltional layer is 4-D.
I have stuck in the issue for two weeks and I'm kind of desperate.
Can anyone help me ?
Thank you
Caffe supports blobs with more than 4 dimensions. If you want to perform temporal convolutions, I suppose you'll need to feed caffe with 5D input blobs with dimensions batch-channels-time-height-width. With this kind of input you can have temporal convolutions simply by changing the default axis argument in the convolution_param. For example:
input: "data"
input_shape: { dim: 5 dim: 15 dim: 3 dim: 227 dim: 227 }
layer {
name: "temporal_conv"
type: "Convolution"
bottom: "data"
top: "temporal_conv"
param { lr_mult: 1 decay_mult: 1 }
param { lr_mult: 2 decay_mult: 0 }
convolution_param {
num_output: 32
kernel_size: 3 kernel_size: 5 kernel_size: 5
pad: 1 pad: 2 pad: 2
stride: 1 stride: 2 stride: 2
axis: 1
}
}
This "temporal_conv" layer uses 3x5x5 kernel (pads the input accordingly) and stride 2 in the spatial domain and 1 in the temporal dimension.
#Shai Thank you for replying! I use HDF5 fromat in data layer for training. Tha data store as five dimensions with the order batch-channels-time-height-width. The prototxt part is
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label"
include: {
phase: TRAIN
}
hdf5_data_param {
source: "path/to/txt"
batch_size: 50
}
}
and I got the error
I0520 21:39:35.705278 30447 net.cpp:84] Creating Layer conv1
I0520 21:39:35.705286 30447 net.cpp:381] conv1 <- data
I0520 21:39:35.705294 30447 net.cpp:339] conv1 -> conv1
I0520 21:39:35.705307 30447 net.cpp:113] Setting up conv1
F0520 21:39:35.705329 30447 base_conv_layer.cpp:14] Check failed: 4 == bottom[0]->num_axes() (4 vs. 5) Input must have 4 axes, corresponding to (num, channels, height, width)
It seems the input blob dimension should be 4. Is there any solution?

Solid fill of an ellipse in python dxf

I'd like to draw filled ellipse with python. This would be easy if I could use PIL oder some other libraries. The problem is I need the ellipse in a .dxf file format. Therefore I used the dxfwrite package. This allows me to draw an ellipse but I couldn't find a way to fill it with a solid color. The following code does draw an ellipse line, but does not fill it.
import dxfwrite
from dxfwrite import DXFEngine as dxf
name = 'ellipse.dxf'
dwg = dxf.drawing(name)
dwg.add(dxf.ellipse((0,0), 5., 10., segments=200))
dwg.save()
Does anybody of you guys know a solution?
The HATCH entity is not supported by dxfwrite, if you use ezdxf this is the solution:
import ezdxf
dwg = ezdxf.new('AC1015') # hatch requires the DXF R2000 (AC1015) format or later
msp = dwg.modelspace() # adding entities to the model space
# important: major axis >= minor axis (ratio <= 1.) else AutoCAD crashes
msp.add_ellipse((0, 0), major_axis=(0, 10), ratio=0.5)
hatch = msp.add_hatch(color=2)
with hatch.edit_boundary() as boundary: # edit boundary path (context manager)
edge_path = boundary.add_edge_path()
# an edge path can contain line, arc, ellipse or spline elements
edge_path.add_ellipse((0, 0), major_axis_vector=(0, 10), minor_axis_length=0.5)
# upcoming ezdxf 0.7.7:
# renamed major_axis_vector to major_axis
# renamed minor_axis_length to ratio
dwg.saveas("solid_hatch_ellipse.dxf")
You could fill an ellipse by using a solid hatch object:
For the above example, here is a snippet from the DXF file that contains the ellipse and the hatch:
AcDbEntity
8
0
100
AcDbEllipse
10
2472.192919
20
1311.37942
30
0.0
11
171.0698134145308
21
-27.61597470964863
31
0.0
210
0.0
220
0.0
230
1.0
40
0.2928953354556341
41
0.0
42
6.283185307179586
0
HATCH
5
5A
330
2
100
AcDbEntity
8
0
100
AcDbHatch
10
0.0
20
0.0
30
0.0
210
0.0
220
0.0
230
1.0
2
SOLID
70
1
71
1
91
1
92
5
93
1
72
3
10
2472.192919357234
20
1311.379420138197
11
171.0698134145308
21
-27.61597470964863
40
0.2928953354556341
50
0.0
51
360.0
73
1
97
1
330
59
75
1
76
1
47
0.794178
98
1
10
2428.34191358924
20
1317.777876434349
450
0
451
0
460
0.0
461
0.0
452
0
462
1.0
453
2
463
0.0
63
5
421
255
463
1.0
63
2
421
16776960
470
LINEAR
1001
GradientColor1ACI
1070
5
1001
GradientColor2ACI
1070
2
1001
ACAD
1010
0.0
1020
0.0
1030
0.0
There are a lot of DXF codes involved. This is the information Autodesk provide:
Hatch group codes
Group code
Description
100
Subclass marker (AcDbHatch)
10
Elevation point (in OCS)
DXF: X value = 0; APP: 3D point (X and Y always equal 0, Z represents the elevation)
20, 30
DXF: Y and Z values of elevation point (in OCS)
Y value = 0, Z represents the elevation
210
Extrusion direction (optional; default = 0, 0, 1)
DXF: X value; APP: 3D vector
220, 230
DXF: Y and Z values of extrusion direction
2
Hatch pattern name
70
Solid fill flag (solid fill = 1; pattern fill = 0); for MPolygon, the version of MPolygon
63
For MPolygon, pattern fill color as the ACI
71
Associativity flag (associative = 1; non-associative = 0); for MPolygon, solid-fill flag (has solid fill = 1; lacks solid fill = 0)
91
Number of boundary paths (loops)
varies
Boundary path data. Repeats number of times specified by code 91. See Boundary Path Data
75
Hatch style:
0 = Hatch “odd parity” area (Normal style)
1 = Hatch outermost area only (Outer style)
2 = Hatch through entire area (Ignore style)
76
Hatch pattern type:
0 = User-defined; 1 = Predefined; 2 = Custom
52
Hatch pattern angle (pattern fill only)
41
Hatch pattern scale or spacing (pattern fill only)
73
For MPolygon, boundary annotation flag (boundary is an annotated boundary = 1; boundary is not an annotated boundary = 0)
77
Hatch pattern double flag (pattern fill only):
0 = not double; 1 = double
78
Number of pattern definition lines
varies
Pattern line data. Repeats number of times specified by code 78. See Pattern Data
47
Pixel size used to determine the density to perform various intersection and ray casting operations in hatch pattern computation for associative hatches and hatches created with the Flood method of hatching
98
Number of seed points
11
For MPolygon, offset vector
99
For MPolygon, number of degenerate boundary paths (loops), where a degenerate boundary path is a border that is ignored by the hatch
10
Seed point (in OCS)
DXF: X value; APP: 2D point (multiple entries)
20
DXF: Y value of seed point (in OCS); (multiple entries)
450
Indicates solid hatch or gradient; if solid hatch, the values for the remaining codes are ignored but must be present. Optional; if code 450 is in the file, then the following codes must be in the file: 451, 452, 453, 460, 461, 462, and 470. If code 450 is not in the file, then the following codes must not be in the file: 451, 452, 453, 460, 461, 462, and 470
0 = Solid hatch
1 = Gradient
451
Zero is reserved for future use
452
Records how colors were defined and is used only by dialog code:
0 = Two-color gradient
1 = Single-color gradient
453
Number of colors:
0 = Solid hatch
2 = Gradient
460
Rotation angle in radians for gradients (default = 0, 0)
461
Gradient definition; corresponds to the Centered option on the Gradient Tab of the Boundary Hatch and Fill dialog box. Each gradient has two definitions, shifted and unshifted. A Shift value describes the blend of the two definitions that should be used. A value of 0.0 means only the unshifted version should be used, and a value of 1.0 means that only the shifted version should be used.
462
Color tint value used by dialog code (default = 0, 0; range is 0.0 to 1.0). The color tint value is a gradient color and controls the degree of tint in the dialog when the Hatch group code 452 is set to 1.
463
Reserved for future use:
0 = First value
1 = Second value
470
String (default = LINEAR)
I hope this may be of some use to you. I apologize if I missunderstood your issue.

How to read a tif image with transparent pixels in opencv

I have a tif image that has transparent pixels (I can see them in paint.net as transparent pixels).
I am trying to read them into a Mat in openCV and I am using this code:
Mat image=imread(imagePathname,CV_LOAD_IMAGE_UNCHANGED);
auto x=image.channels();
based on I my understanding, since the input image has transparency, channels() should return 4, but it return 3.
How can I read a tif image with transparent pixels and checking if a pixel is transparent in opencv?
edit1
Result of running imagemagick:
Image: layer0003.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 10000x5000+0+0
Resolution: 150x150
Print size: 66.6667x33.3333
Units: PixelsPerInch
Type: TrueColorAlpha
Base type: TrueColor
Endianess: MSB
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 23.6472 (0.0927342)
standard deviation: 37.6851 (0.147785)
kurtosis: 8.93054
skewness: 2.28009
Green:
min: 0 (0)
max: 255 (1)
mean: 22.8353 (0.0895504)
standard deviation: 37.6516 (0.147653)
kurtosis: 10.4255
skewness: 2.52881
Blue:
min: 0 (0)
max: 255 (1)
mean: 22.798 (0.0894041)
standard deviation: 37.6575 (0.147677)
kurtosis: 10.9059
skewness: 2.58999
Alpha:
min: 0 (0)
max: 255 (1)
mean: 89.055 (0.349235)
standard deviation: 121.566 (0.476728)
kurtosis: -1.59995
skewness: -0.632496
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 58.8064 (0.230613)
standard deviation: 68.9821 (0.270518)
kurtosis: 8.35337
skewness: 3.53852
Alpha: none #00000000
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 10000x5000+0+0
Dispose: Undefined
Iterations: 0
Compression: LZW
Orientation: TopLeft
Properties:
date:create: 2014-03-01T13:11:12+00:00
date:modify: 2014-02-28T17:48:41+00:00
signature: dfa3e35c35345ef3440ff15d15ad37222f9cf0376bed7b7710dd95f4e537e210
tiff:alpha: unassociated
tiff:endian: lsb
tiff:photometric: RGB
tiff:rows-per-strip: 1
tiff:timestamp: 2014:02:28 17:48:38
xmp:CreatorTool: Microsoft Windows Live Photo Gallery 15.4.3555.308
Profiles:
Profile-xmp: 12702 bytes
Artifacts:
filename: layer0003.tif
verbose: true
Tainted: False
Filesize: 20.42MB
Number pixels: 50M
Pixels per second: 60.24MB
User time: 0.827u
Elapsed time: 0:01.829
Version: ImageMagick 6.8.8-7 Q16 x64 2014-02-13 http://www.imagemagick.org
I just had some time to revisit this :-)
Basically, I think the issue is that ImageMagick will adopt the most economical, in terms of file size, when writing its output files. So, if your image is basically greyscale but the alpha (opacity) channel is only 0 or 1, ImageMagick will encode that with 16-bit greyscale for the data and single-bit alpha channel. I guess that is beyond OpenCV as it seems to expect the alpha to be encoded with the same depth as the data.
So, the question becomes... "How can you force the combination you need of data/alpha (both 8-bit, not 8-bit plus 1-bit) greyscale/colour (8-bit greyscale or 8-bit colour)?"
There may be other ways, but for now, I can envisage adding a row across the bottom of the image that forces ImageMagick's hand and which you can hopefully readily remove once it has done the trick for you in OpenCV.
So, let's create a 16-bit greyscale image with a single-bit alpha where it makes the square transparent hole in the middle:
convert -size 300x300 gradient:black-white -alpha set -region 100x100+100+100 -alpha transparent image.tif
Let's check what we have:
identify -verbose image.tif | head -14
Image: image.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 300x300+0+0
Units: PixelsPerInch
Type: GrayscaleAlpha
Base type: Grayscale
Endianess: LSB
Colorspace: Gray
Depth: 16-bit
Channel depth:
gray: 16-bit <--- 16-bit greyscale data
alpha: 1-bit <--- 1-bit alpha
Now let's force it to 8-bit alpha and 8-bit data:
# Force to at least 8-bit greyscale (but maybe RGB depending on rest of image) plus 8-bit alpha...
# ... by adding a line across the bottom with alpha varying from 0 to 1 (i=x coordinate,w=width)
convert image.tif \
\( +clone -resize x1! -channel A -fx "i/w" \) \
-append -depth 8 result.tif
Let's check it worked:
identify -verbose result.tif | head -16
Image: result.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 300x301+0+0 <--- one extra row
Units: PixelsPerInch
Type: GrayscaleAlpha
Base type: Grayscale
Endianess: LSB
Colorspace: Gray
Depth: 8-bit
Channel depth:
gray: 8-bit <--- 8-bit data
alpha: 8-bit <--- 8-bit alpha
Now let's force 8-bit RGB plus 8-bit alpha:
# Force to 8-bit RGB plus 8-bit alpha...
# ... by adding a coloured line across the bottom with alpha varying from 0 to 1 (i=x coordinate,w=width)
convert image.tif \
\( +clone -resize x1! -channel RGBA -fx "rand()" \) \
-append -depth 8 result.tif
And let's check again:
Image: result.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 300x301+0+0 <--- 1 extra row
Units: PixelsPerInch
Type: TrueColorAlpha
Base type: TrueColor <--- Truecolour
Endianess: LSB
Colorspace: sRGB <--- RGB
Depth: 8-bit
Channel depth:
red: 8-bit <--- 8-bit red
green: 8-bit <--- 8-bit green
blue: 8-bit <--- 8-bit blue
alpha: 8-bit <--- 8-bit alpha

How to generate an XML file for face detection

Now I am creating my own classifier for face detection.now I want to train the classifier.So when I give the command 'opencv_haartraining -data facehaar -vec vecfile.vec -bg negatives.txt -npos 3 -nneg 5 -nstages 30 -w 30 -h 32' it shows like this.What is this error?I don't understand?Could any one help me?
Data dir name: facehaar
Vec file name: vecfile.vec
BG file name: negatives.txt, is a vecfile: no
Num pos: 3
Num neg: 5
Num stages: 30
Num splits: 1 (stump as weak classifier)
Mem: 200 MB
Symmetric: TRUE
Min hit rate: 0.995000
Max false alarm rate: 0.500000
Weight trimming: 0.950000
Equal weights: FALSE
Mode: BASIC
Width: 30
Height: 32
Applied boosting algorithm: GAB
Error (valid only for Discrete and Real AdaBoost): misclass
Max number of splits in tree cascade: 0
Min number of positive samples per cluster: 500
Required leaf false alarm rate: 9.31323e-10
Tree Classifier
Stage
+---+
| 0|
+---+
Number of features used : 234720
Parent node: NULL
*** 1 cluster ***
POS: 3 3 1.000000
Invalid background description file.