According to the output by WEKA below, some of the Weighted Avg. has values but the other has a question mark. For TP Rate, the Weighted Avg. is calculated even though there are two question marks at STM_TA and UM_KRTN rows. But, it not calculated for Precision, F-Measure and MCC.
=== Detailed Accuracy By Class ===
TP Rate FP Rate Precision Recall F-Measure MCC ROC Area PRC Area Class
0.714 0.000 1.000 0.714 0.833 0.845 1.000 1.000 MEA0072
0.818 0.001 0.818 0.818 0.818 0.817 0.999 0.913 MEA0095
0.885 0.001 0.958 0.885 0.920 0.920 1.000 0.983 MEA1061
1.000 0.001 0.981 1.000 0.990 0.990 1.000 0.999 MEA2087
0.846 0.001 0.846 0.846 0.846 0.845 1.000 0.965 MEA2098
0.938 0.001 0.938 0.938 0.938 0.937 1.000 0.968 MEA2099
0.971 0.001 0.943 0.971 0.957 0.956 0.999 0.973 MEB0079
0.917 0.000 1.000 0.917 0.957 0.957 1.000 1.000 MEE0075
1.000 0.001 0.967 1.000 0.983 0.983 1.000 1.000 MFT0001
0.930 0.001 0.976 0.930 0.952 0.952 0.999 0.967 MFT0002
1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000 MFT0003
1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000 MFT1001
0.944 0.002 0.850 0.944 0.895 0.895 1.000 0.986 MFT1002
1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000 MFT1003
1.000 0.001 0.975 1.000 0.987 0.987 1.000 0.999 MFT2001
1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000 MRA1002
1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000 MRA2125
1.000 0.001 0.984 1.000 0.992 0.992 1.000 1.000 MRA2127
? 0.000 ? ? ? ? ? ? STM_TA
0.786 0.051 0.793 0.786 0.790 0.737 0.948 0.818 STM_TL
0.547 0.106 0.553 0.547 0.550 0.443 0.848 0.588 STM_TT
0.000 0.000 ? 0.000 ? ? 0.894 0.064 STM_X
0.547 0.008 0.806 0.547 0.652 0.649 0.978 0.762 UM_KK
0.864 0.082 0.787 0.864 0.824 0.760 0.941 0.815 UM_KRK
? 0.000 ? ? ? ? ? ? UM_KRTN
Weighted Avg. 0.797 0.053 ? 0.797 ? ? 0.943 0.816
=== Confusion Matrix ===
a b c d e f g h i j k l m n o p q r s t u v w x y <-- classified as
5 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 | a = MEA0072
0 9 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | b = MEA0095
0 0 23 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 | c = MEA1061
0 0 0 51 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | d = MEA2087
0 2 0 0 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | e = MEA2098
0 0 0 0 1 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | f = MEA2099
0 0 0 0 0 0 33 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | g = MEB0079
0 0 0 0 0 0 0 11 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 | h = MEE0075
0 0 0 0 0 0 0 0 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | i = MFT0001
0 0 0 1 0 0 2 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | j = MFT0002
0 0 0 0 0 0 0 0 0 0 23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | k = MFT0003
0 0 0 0 0 0 0 0 0 0 0 45 0 0 0 0 0 0 0 0 0 0 0 0 0 | l = MFT1001
0 0 1 0 0 0 0 0 0 0 0 0 17 0 0 0 0 0 0 0 0 0 0 0 0 | m = MFT1002
0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 | n = MFT1003
0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 0 0 0 0 0 0 0 0 0 0 | o = MFT2001
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 55 0 0 0 0 0 0 0 0 0 | p = MRA1002
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 58 0 0 0 0 0 0 0 0 | q = MRA2125
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 0 0 0 0 0 0 0 | r = MRA2127
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | s = STM_TA
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 302 70 0 2 10 0 | t = STM_TL
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 51 204 0 12 106 0 | u = STM_TT
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 1 0 | v = STM_X
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 45 0 58 0 0 | w = UM_KK
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 43 0 0 433 0 | x = UM_KRK
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | y = UM_KRTN
I had searched through the internet, but there is no answer for the question mark at Weighted Avg. I hope anyone could help me to explain why some of them are calculated but not others?
Thank you
The '?' is used in Weka instead of NaN (not a number) due to due to zero denominator. E.g. in your case, the precision for class STM_X is ‘?’ that there are no instances assigned to the class, thus denominator is zero. Furthermore, STM_TA and UM_KRTN have no samples at all.
When '?' symbols appear in the output, the specific class may have not enough samples or none of the samples can be assigned to the class. In your case, two classes have no samples at all, thus provides ‘?’ for all metrics. In the case presented, the weighted average for TP, FP, Recall, ROC and PRC has value although there ‘?’ in its columns.
Note that, the class STM_TA and UM_KRTN has ‘?’ for all metrics except FP (because there is no false positive due to no samples at all), thus ‘?’ in the column can be just 0 and weighted average can be calculated. However, for STM_X, there are 8 samples but none of the samples can be assigned correctly to class, therefore NaN or ‘?’ and weighted average could not be calculated.
The ? (undetermined) values are propagating. Note in the lines above you have some values that are also ?. Note you have some classes that no instances were classified in.
Related
I am trying to convert a Format_Grayscale8 image to Format_ARGB32 (or any other 8bpp RGB format). I tried to use QImage::convertToFormat and a color table but I can't make it work. The input is a small 8bit gray image (PGM format text string).
QImage img;
img.loadFromData(gray_map.toLatin1());
QImage heatmap = img.convertToFormat(QImage::Format_Indexed8, color_gradient.getColorMap());
Doing it manually works fine (pixel per pixel):
// gray_img format is QImage::Format_Grayscale8
QImage createHeatMap(QImage gray_img)
{
QImage heatmap(gray_img.width(), gray_img.height(), QImage::Format_ARGB32);
// custom heatmap, size() is 256
const QVector<QRgb> color_map = color_gradient.getColorMap();
// Default color
heatmap.fill(color_map[0]);
for (int y = 0; y < gray_img.height(); y++)
{
for (int x = 0; x < gray_img.width(); x++)
{
const uchar* img_ptr = gray_img.bits();
int offset = x + y*gray_img.bytesPerLine();
uchar gray_pix = *(img_ptr + offset);
// just in case
if (gray_pix < color_map.size())
heatmap.setPixel(x, y, color_map[gray_pix]);
}
}
return heatmap;
}
QImage img;
img.loadFromData(doppler_map.toLatin1());
QImage heatmap = createHeatMap(img);
I am interested in a simpler and more efficient solution. Thanks!
EDIT
Here is the code to generate the color gradient:
// Heatmap color lookup table generator, inspired from:
// http://www.andrewnoske.com/wiki/Code_-_heatmaps_and_color_gradients
#include <QColor>
class ColorGradient
{
private:
struct ColorPoint
{
float r, g, b;
float val; // Position of our color along the gradient (between 0 and 1).
ColorPoint(float red, float green, float blue, float value)
: r(red), g(green), b(blue), val(value)
{
}
};
std::vector<ColorPoint> mColors; // An array of color points in ascending value.
uint mTableSize = 0;
QVector<QRgb> mColorMap;
// hidden
ColorGradient();
public:
inline auto getColorMap()
{
return mColorMap;
}
ColorGradient(uint table_size)
{
createDefaultHeatMapGradient(table_size);
}
//-- Places a 6 color heapmap gradient into the "color" vector
#define CF64(val) ((float)(val) / 64.0)
#define CF256(val) ((float)(val) / 256.0)
void createDefaultHeatMapGradient(uint table_size)
{
mTableSize = table_size;
mColorMap.clear();
mColors.clear();
// ascending order
mColors.push_back(ColorPoint(0, 0, CF256(96), CF64(00))); // Dark Blue
mColors.push_back(ColorPoint(0, 0, 1, CF64(06))); // Blue
mColors.push_back(ColorPoint(0, 1, 1, CF64(22))); // Cyan
mColors.push_back(ColorPoint(1, 1, 0, CF64(39))); // Yellow
mColors.push_back(ColorPoint(1, 0, 0, CF64(55))); // Red
mColors.push_back(ColorPoint(CF256(159),0, 0, CF64(63))); // Dark Red
QColor color;
// Generate the color table
for (uint n = 0; n < table_size; n++)
{
float value = (float)n / (float)table_size;
bool found = false;
for (int i = 0; i < mColors.size(); i++)
{
ColorPoint &currC = mColors[i];
if (value < currC.val)
{
ColorPoint &prevC = mColors[std::max(0, i - 1)];
float valueDiff = (prevC.val - currC.val);
float fractBetween = (valueDiff == 0) ? 0 : (value - currC.val) / valueDiff;
float r = (prevC.r - currC.r)*fractBetween + currC.r;
float g = (prevC.g - currC.g)*fractBetween + currC.g;
float b = (prevC.b - currC.b)*fractBetween + currC.b;
color.setRgbF(r, g, b);
mColorMap.append(color.rgb());
found = true;
break;
}
}
if (!found)
{
color.setRgbF(mColors.back().r, mColors.back().g, mColors.back().b);
mColorMap.append(color.rgb());
}
}
}
};
And a sample text image file:
P2
40 17
64
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 7 7 7 7 7 7 7 7 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 13 13 13 13 13 13 13 13 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 10 10 10 10 10 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 14 14 14 14 14 14 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 23 23 23 23 23 23 23 23 23 23 23 23 23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 13 13 13 13 13 13 13 13 13 13 13 13 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The trick is to first convert to QImage::Format_Indexed8 without any color map, and set it in a separate call:
QImage heatmap = img.convertToFormat(QImage::Format_Indexed8);
heatmap.setColorTable(color_gradient.getColorMap());
After this, you can make a second conversion to QImage::Format_RGB888 or whatever you need.
I got some problem when I use img.at(y,x) to access pixel value in C++, here is my code:
int main( int argc, char** argv )
{
Mat image;
image = imread("a.jpg",-1);
int a;
for(int x = 0; x<image.rows;x++)
{
cout<<endl;
for(int y = 0; y< image.cols; y++)
{
a = (int)image.at<uchar>(y,x);
if(a>200)
{
cout<<"1 ";
}else{
cout<<a<<" ";
}
}
}
}
so the function is going to iterate all pixel then if it is 255 print 1, rest remains.
Here is the a.jpg image:
but it prints out like that
0 0 0 0 0 0 1 0 1 0 0 0 7 0 0 7 0 0 0 1 0 1 0 0
0 0 0 0 0 0 0 0 0 3 1 0 0 0 0 0 0 1 3 0 0 0 0 0
0 0 0 0 0 0 0 5 0 2 0 1 0 1 1 0 1 0 2 0 5 0 0 0
0 0 0 0 0 0 1 0 0 2 0 2 0 1 1 0 2 0 2 0 0 1 0 0
0 0 0 0 0 0 0 2 0 1 0 0 1 1 1 0 0 0 2 0 2 0 0 0
0 0 0 0 0 0 4 0 0 1 1 1 1 1 1 1 1 0 0 2 0 3 0 0
0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 1 2 0 0 0 0 0
0 0 0 0 0 0 0 4 0 1 1 1 1 1 1 1 1 0 1 0 1 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 2 0 2 0 1 0 0 0
0 0 0 0 0 0 0 1 1 1 1 1 1 0 2 0 0 0 2 0 2 0 0 0
0 0 0 0 0 0 1 1 1 1 1 1 0 2 0 0 2 2 0 1 0 0 0 0
0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 3 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 5 1 1 4 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 4 0 0 2 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 3 0 0 0 2 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 3 0 1 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 2 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 2 0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 1 0 0 0 7 0 0 7 0 0 0 1 0 1 0 0 0
0 0 0 0 0 0 0 0 3 1 0 0 0 0 0 0 1 3 0 0 0 0 0 0
0 0 0 0 0 0 5 0 2 0 1 0 1 1 0 1 0 2 0 5 0 0 0 0
0 0 0 0 0 1 0 0 2 0 2 0 1 1 0 2 0 2 0 0 1 0 0 0
0 0 0 0 0 0 2 0 1 0 0 1 1 1 0 0 0 2 0 2 0 0 0 0
0 0 0 0 0 4 0 0 1 1 1 1 1 1 1 1 0 0 2 0 3 0 0 0
0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 1 2 0 0 0 0 0 0
0 0 0 0 0 0 4 0 1 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0
0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 2 0 2 0 1 0 0 0 0
0 0 0 0 0 0 1 1 1 1 1 1 0 2 0 0 0 2 0 2 0 0 0 0
does anyone know the reason? I have tried 8bit jpg, 16 bit tiff, png, output are all pretty weird, which should be image shape(white part)
it works fine on python that is the most weird thing
any help appreciated!
In your code you have set x to be row and y to be column. You have to interchange the variables when you are reading from the matrix. This formulation is row order and not column order.
a = (int)image.at<uchar>(x,y);
You can also read the following SO post about the confusion between row order and column order.
image = imread("a.jpg", CV_LOAD_IMAGE_GRAYSCALE);
I have a PEM Certificate generated using OpenSSL. The certificate is read using fopen call in C++. The X509 object is then copied into an unsigned char array using memcpy, and the ascii values of the array are displayed.
When I repeat the same process (reading the file, and displaying the ascii values), the results differ. Results differ across executions, as well as in the same execution.
This is how I am reading the certificate
FILE* f_cert = fopen(filename.str().c_str(), "r");
X509 *tempCert = NULL;
PEM_read_X509(f_cert, &tempCert, NULL, NULL);
This is how I display the certificate
memcpy (temp, tempCert, sizeof(Certi));
for (int a=0; a<sizeof(X509); a++){
cout << (int)temp[a] << " ";
}
Output-1:
16 216 64 1 0 0 0 0 128 223 64 1 0 0 0 0 160 223 64 1 0 0 0 0 0 0 0 0
1 0 0 0 208 232 64 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255
255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Output-2:
16 216 212 0 0 0 0 0 128 223 212 0 0 0 0 0 160 223 212 0 0 0 0 0 0 0 0
0 1 0 0 0 208 232 212 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255
255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
But when I read the certificate's MD5, it stays the same. What could be an explanation for this?
I need to insert this certificate into a Bloom Filter.
Thanks in advance.
I want to determine if a CU has been intra or inter encoded with the HEVC reference software HM 16.4 encoder.
In TEncSlice.cpp, after a CTU has been compressed (m_pcCuEncoder->compressCtu( pCtu );), I should be able to tell if a CU is intra or inter encoded.
Therefore, I check the m_pePredMode array of TComDataCU* pCtu:
Char* predMode = pCtu->getPredictionMode();
for (int i = 0; i < pCtu->getTotalNumPart(); i++)
{
std::cout << (int)predMode[i] << " ";
}
std::cout << std::endl;
PredMode is defined in TypeDef.h as:
enum PredMode
{
MODE_INTER = 0, ///< inter-prediction mode
MODE_INTRA = 1, ///< intra-prediction mode
NUMBER_OF_PREDICTION_MODES = 2,
};
The output of my code first gives me the expected result. For the first intra frame, I first only get ones (MODE_INTRA). But for certain CTUs, I also get "twos", which doesn't really make sense to me, as 2 is not supposed to describe a prediction mode.
Similarly, in the inter frames (P frames), I mostly get zeros (MODE_INTER), a few ones (MODE_INTRA), which is ok. But then I also get some "twos". A part of an example output looks like this (each row corresponds to a 64x64 CTU):
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Does anyone know what these mean? I checked if this would correspond to skip mode, but there was no correlation between the skip flag and the 2s.
Well, I got the answer to this question:
If a CU has predMode 2, this means that the CU is not coded. This happens in this case because the CUs are outside the boundaries of the picture.
The sequence that was coded had a resolution of 416x240 and the CTU size was 64x64. So there are 6.5 CTUs in a row.
This explain why every 7 CTUs, I get 2s as predMode.
I have the following data written on a file. I want to neglect all the zeros in the beginning and the but the starting from 181 in an array each number in a cell so I could use it easily.
I know how to put data in an array but how could I neglect all these zeros ??
0 177 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 181 98 1 2 28 0 104 93 165 3 7 110 239 5 172 164 176 29 56 147 4 0 234 215 3 0 166 6 0 0 78 5 0 0 164 145 181 98 1 2 28 0 80 97 165 3 7 110 239 5 172 164 176 29 56 147 4 0 234 215 3 0 169 6 0 0 78 5 0 0 147 117 181 98 1 2 28 0 56 101 165 3 7 110 239 5 172 164 176 29 56 147 4 0 234 215 3 0 173 6 0 0 81 5 0 0 134 109 181 98 1 2 28 0 32 105 165 3 7 110 239 5 172 164 176 29 56 147 4 0 234 215 3 0 181 6 0 0 85 5 0 0 126 137 181 98 1 2 28 0 8 109 165 3 7 110 239 5 172 164 176 29 56 147 4 0 234 215 3 0 182 6 0 0 87 5 0 0 109 101
I am not sure I understand your question, so I will post multiple answers. Choose the one that fits with your problem's description.
Case 1: ignore everything before(or before and including) 181:
#include <iostream>
#include <fstream>
#include <vector>
int main() {
std::ifstream in("input.txt");
std::vector<int> vec;
int reached_181 = 0, x;
while(in >> x) {
if(x == 181) reached_181 = 1;
if(reached_181) vec.push_back(x);
// if you also want to neglect 181 then just change the order of the two commands
// if(reached_181) vec.push_back(x);
// if(x == 181) reached_181 = 1;
}
for(std::vector<int>::size_type i=0; i<vec.size(); ++i) {
std::cout << vec[i] << " ";
}
return 0;
}
Case 2: ignore every zero before 181
#include <iostream>
#include <fstream>
#include <vector>
int main() {
std::ifstream in("input.txt");
std::vector<int> vec;
int reached_181 = 0, x;
while(in >> x) {
if(x == 181) reached_181 = 1;
if(reached_181 || x) vec.push_back(x);
}
for(std::vector<int>::size_type i=0; i<vec.size(); ++i) {
std::cout << vec[i] << " ";
}
return 0;
}
Case 3: ignore all the zeroes in the input file
#include <iostream>
#include <fstream>
#include <vector>
int main() {
std::ifstream in("input.txt");
std::vector<int> vec;
int x;
while(in >> x) {
if(x) vec.push_back(x);
}
for(std::vector<int>::size_type i=0; i<vec.size(); ++i) {
std::cout << vec[i] << " ";
}
return 0;
}
Try this:
#include <fstream>
#include <vector>
#include <iostream>
int main()
{
std::vector<int> v;
std::fstream out("out.txt"); // name of your file
bool hit;
for (int n; (out >> n);)
{
if (n == 181 && !hit)
hit = true;
if (!hit)
if (n)
v.push_back(n);
if (hit)
v.push_back(n);
}
typedef std::vector<int>::const_iterator iter_type;
for (iter_type it = v.begin(); it != v.end(); ++it)
std::cout << *it << std::endl;
}