How do I get an entire row in a single line? - python-2.7

I have this code:
count_vect = CountVectorizer()
freq_matrix = count_vect.fit_transform(df.Text).todense()
print freq_matrix
df.text contains tweets.A bag of words is created in alphabetical order and frequency matrix is the occurrences of these words in each tweet.
When I print the matrix after every 37th column a new line is added.
like this-
[[0 1 1 0 0 0 0 0 1 0 1 0 0 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 0 0 0 0 0 0 0 1 0 0 0 1]
[1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 1 0 0 0 1 0 0 1 0]
...
Whereas I thought that for a single row all the columns will be in a single line. How can I get them in a single line?

Related

How to maintain order when iterating over a Map in Clojure?

I have the following map:
(def tmp-cust-data {:customers
{:january [1 0 2 0 3 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]
:february [0 1 0 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
:march [0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
:april [1 0 2 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 ]
:may [1 0 2 0 3 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
:june [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]
:july [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
:august [1 0 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
:september [1 0 2 0 3 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
:october [1 0 2 0 3 0 4 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
:november [1 0 2 0 3 0 4 0 5 0 6 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]
:december [1 0 2 0 3 0 4 0 5 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]}})
When I do something like doseq over that map, I notice the order isn't preserved:
(doseq [[k v] (:customers tmp-cust-data)] (println k))
Is there a proper way to iterate over a map while preserving the order?
Use an ordered version of the map.
(def tmp-cust-data {:customers
(flatland.ordered.map/ordered-map
[[:january [1 0 2 0 3 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]]
[:february [0 1 0 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[:march [0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[:april [1 0 2 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]]
[:may [1 0 2 0 3 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[:june [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]]
[:july [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[:august [1 0 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[:september [1 0 2 0 3 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[:october [1 0 2 0 3 0 4 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[:november [1 0 2 0 3 0 4 0 5 0 6 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[:december [1 0 2 0 3 0 4 0 5 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]])})
A hash map is inherently unordered by definition. You can choose an order for your keys and you can then iterate over those keys in order and access the hash map values, but the hash map itself cannot possibly have "an order".

C++: problems reading a Bitmap image

I'm currently writing a function that will manipulate a 512x512 .BMP image and I'm struggling with reading in the pixel data. I'm including fstream in this to deal with reading the image data.
My function should work explicitly with 8-bit Grayscale .BMP images, so I really shouldn't need to worry about the file Headers. You can see in my code I just read the entire header into an array for later usage.
Here is my Constructor for my Image Class:
// Constructor
Image::Image(const char* inFileName){
// First we will initialize our Image Data Arrays:
ImageData = new int* [SIZE];
complexImageData = new complex<double>* [SIZE];
for(int i=0; i<SIZE; ++i){
ImageData[i] = new int [SIZE];
complexImageData[i] = new complex<double> [SIZE];
}
// Now we will initialize our I/O Files.
outFile = new ofstream;
inFile = new ifstream;
// And now we will fill our data arrays with the input file data.
inFile->open(inFileName,ios::in | ios::binary); // Reads file as binary
inFile->seekg(0,ios::beg); // sets filter position to beginning
inFile->read(header,HEADERSIZE); // Reads header
// Now to read in the image data:
for(int i=0; i<SIZE; ++i){
inFile->read(reinterpret_cast<char*>(ImageData[i]),SIZE);
for(int j=0; j<SIZE; ++j){
cout << ImageData[i][j] << ' ';
}
cout << endl;
}
inFile->close();
}
As you can see, it prints out the data as it is read in. The output of this constructor is strange to me. Here's the first 512 entries read into the ImageData array:
236854814 237117986 505286158 236854814 505290270 236854814 572662306 237112866 571346462 505290254 505288222 371072534 236328478 504763918 370546198 152442390 503911958 236330518 370546198 152439062 369690902 504763926 236852758 571347470 572662306 571351570 235802142 504237582 505290254 236330526 504241694 235802126 505290262 370546206 370548246 504765974 371070494 505288214 371072534 369694230 235806222 236854814 237117986 235802146 370548254 369690902 504763926 371072534 370546198 152442390 504760598 504763926 237117986 304226850 235802146 235802126 235807246 504241678 504761870 504237590 371072542 370548246 504763926 236854806 235802142 235802126 235802126 504242702 235802126 303178258 505286178 571351566 572662286 572658210 236065314 303178254 571609618 571351586 571613730 571351586 237112866 571351566 303702562 572658210 237112846 304222754 303700506 304226850 168434194 471079956 169088010 169088020 437914122 437918234 169085466 436865546 169482778 336204810 168430100 336857610 336862228 336204820 471077898 471866380 471079964 169090076 203168778 169088012 471077914 336862236 168430090 168434186 168434202 437918234 169482778 168430106 168430106 169482762 336206346 169085450 336206356 135796768 404228120 270014488 303698458 303174162 303174162 404752922 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
As you can see, approximately the second half of this data is all zeros. Another line is even stranger:
236852766 571346446 236850702 371072542 505291278 371070494 504763934 236330518 370548238 503911966 236852758 371072542 504763913 504237582 571350542 235802126 504242722 503911958 152966678 370542870 369694230 369690905 236330505 504237590 370548246 504763926 370546206 370546198 370546198 235806230 371073550 504763926 370548254 572658206 235807246 571346446 504237582 236854798 505553422 370548254 152442390 236852758 572662306 504765986 370546198 369694217 504763926 370548246 504241686 371072526 235804190 504765974 370542870 151587081 152635673 504763913 369690902 370546206 152443145 505290262 236852766 371072534 505284886 370546206 572397078 371072526 504237598 370548254 371070486 371073566 152439049 370542870 152442377 504763926 571350558 505286174 504765982 236854814 235806238 235802126 235807246 572399134 571351566 571613730 571611666 303698466 437916186 169478682 168430090 169089546 336862236 336860180 336204810 336857620 336202260 168432660 168430090 168430106 471075338 203431964 470551564 336202250 336860180 336860180 336862228 336204820 168430100 436865562 337384458 436868106 168430090 168430090 336204820 436865546 168430090 168432650 269487114 135796760 202905624 437918226 437918234 403705868 404232208 269490200 337252884 571613722 304222738 269228562 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 181497 53543152 0 53543152 0 57016416 0 57016416 0 57135104 0 925696 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
You can see that it also has the same zeros, but amongst those zeros are some unexpected non-zero entries. This is certainly not expected from the input image.
Any help would be greatly appreciated! I'm sorry if this is a duplicate but I tried so very hard to find an answer to my problem before posting this!
EDIT:
I noticed immediately that the numbers being printed (236854814, 237117986 etc) were not in the 8-bit range. I find this so confusing since I'm reading the data reinterpreted as a char, which is 8-bit on my system. Would it not be the case that the data being read into the integer array should be 8-bit? I even tried making my ImageData array of type __int8**, so that it could only store 8 bits per entry, but It still didn't work.
Your image is 8bpp grayscale but you read it into block int [SIZE] (supplying wrong buffer size in the process) potentially storing 4 pixel values in each int. If image is 8bpp you could've just used uint8_t buffer. You should also perform header validation (because right now your may read at wrong position) and check for actual amount of bytes read. Depending on image type / size you may also need to check padding for each line.

c++ opencv access pixel value incorrect

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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 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);

HM encoder 16.4 predMode is 2

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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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.

C++ Finding a integer value in a .txt file

I have a map.txt file:
[Map]
0 0 0 0 0 0 0 0 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 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I also have a square on my screen that fills in the tile that my mouse has clicked on. The problem I have is I want to be able to edit the map.txt file by changing a value of it according to where on the map I click. I need to know if there is a way I can access a certain value in the map file, like an array. So for example getting Collision[5][8] or Details[7][17], etc. Thanks!
http://screencast.com/t/gqH18wgW (This shows the clicking to find the location)
While you could store the location in the file of each cell and overwrite individual cells, this only works if the old and new strings are the same length.
A more flexible and very straightforward way is to:
Parse the file into an array. (see Read integers from a text file with C++ ifstream)
Update the array whenever the user clicks.
When finished, turn the array back into a file.