c++ opencv access pixel value incorrect - c++

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

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

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

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?

Issue to send data to server via Web Service

I have some issue where I wanted to send this information via web service. My program is using MFC 6.0. There are several other functions besides this UploadStripMapping and other functions works well. Somehow, I have some issue here where this data is not captured in the server's log. But, if I send data with wrong XML format, then the server will reply with format error.
Below is the statement that I wanted to send over:
<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <UploadStripMapping xmlns="http://tempuri.org/"> <strXML><?xml version="1.0" encoding="utf-8"?>
<root>
<info>
<StripID>1234ABDD</StripID>
<LotID>B Version</LotID>
<Rows>18</Rows>
<Columns>48</Columns>
<Panels>4</Panels>
<MachineID>3RD019</MachineID>
<DateCreated>2016-07-04 13:27:43</DateCreated>
</info>
<Mapping>
<Col1>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col1>
<Col2>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col2>
<Col3>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col3>
<Col4>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col4>
<Col5>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col5>
<Col6>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col6>
<Col7>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col7>
<Col8>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col8>
<Col9>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col9>
<Col10>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col10>
<Col11>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col11>
<Col12>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col12>
<Col13>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col13>
<Col14>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col14>
<Col15>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col15>
<Col16>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col16>
<Col17>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col17>
<Col18>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col18>
<Col19>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col19>
<Col20>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col20>
<Col21>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col21>
<Col22>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col22>
<Col23>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col23>
<Col24>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col24>
<Col25>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col25>
<Col26>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col26>
<Col27>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col27>
<Col28>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col28>
<Col29>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col29>
<Col30>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col30>
<Col31>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col31>
<Col32>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col32>
<Col33>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col33>
<Col34>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col34>
<Col35>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col35>
<Col36>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col36>
<Col37>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col37>
<Col38>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col38>
<Col39>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col39>
<Col40>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col40>
<Col41>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col41>
<Col42>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col42>
<Col43>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col43>
<Col44>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col44>
<Col45>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col45>
<Col46>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col46>
<Col47>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col47>
<Col48>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</Col48>
</Mapping>
</root></strXML> </UploadStripMapping> </soap12:Body> </soap12:Envelope>
Here's how I write the send statement in my program, the data above I set as strXML:
HTTPMethod = _bstr_t( "POST" );
httpReq->open(HTTPMethod, HTTPUrl, _variant_t(VARIANT_FALSE), _variant_t(), _variant_t());
httpReq->setRequestHeader("Content-Type", "application/soap+xml");
szRequest.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?> \ <soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"> \
<soap12:Body>\
<UploadStripMapping xmlns=\"http://tempuri.org/\"> \
<strXML>\ %s \ </strXML>\
</UploadStripMapping>\
</soap12:Body>\
</soap12:Envelope>", strXML);
vRequest.vt = VT_BSTR;
vRequest.bstrVal = szRequest.AllocSysString();
httpReq->send(vRequest);
bsResponse = httpReq->responseText;
Can anyone give some advice or point out my mistake in this code? Thanks for your help in advance.

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