3/22/2018

Extract the value of interest rows and copy that to new Mat

Simple example code.

using push_back
#gistcode

#end code

using concate
#start code

#end code


Check the rect contains point, opencv tip

https://docs.opencv.org/master/d2/d44/classcv_1_1Rect__.html#a367d5be1a40cc9d423f765ebf2721ee8


Use this function "Rect.contains(Point)".
example:

Rect roi(10,10,20,20);
Point pt(14,14);

if (roi.contains(pt))
  cout << "The pt inside in the rect" << endl;


Thank you.

3/16/2018

simple tip: int to string in stl

memo for me.. ^^

for(int i=0; i<10; ++i)
     std::string index1("string_" + std::to_string(i) + ".jpg");



3/02/2018

Tensorflow RNN LSTM weight save and restore example code

I have been struggled for long time for save and restore the result of LSTM params.
Today, I have succeeded, I hope anyone helping this my example code.


Below code is example to learning for
input: hihell -> output: ihello

gist code start
This code is referenced by this(https://github.com/MareArts/DeepLearningZeroToAll/blob/master/lab-12-1-hello-rnn.py)

gist code end

There are 4 variable for trainable
name rnn/basic_lstm_cell/weights:0, shape (10, 20)
name rnn/basic_lstm_cell/biases:0, shape (20,1)
name fully_connected/weights:0, shape (5, 5)
name fully_connected/biases:0, shape (5,1)

And I have checked the values which are same after "global_variables_initializer"
The result is same and prediction result is also same.

OK, then let's move more complicated RNN design.
This example code for 2 layer LSTM and 2 batch condition.
gist code start

gist code end


Maintain




Reference

2/04/2018

python csv file data simple handler.

I made simple class witch is to handle element datas in csv file.

Basically, we can get elements by indexing.
For example) Get first line row data, or 2~3 line row data.

And we also can get some part of elements in csv.
For example) row 2~3 and col 2~4.

refer to this image




And we can save new csv file.

Actually, I made this class for handle MNIST data file.
And the source code uploaded in GitHub repository.
https://github.com/MareArts/csv_file_handle 
I hope someone updated this code.
Anyone can do contributor.

And I hope to help this code to someone. ^^


.code.

.code.

1/14/2018

Histogram Equalization, Stretching, origin histo compare and example source code

Example source code for histogram equalization
and compare with origin histogram and stretching histogram.

result is like that:

origin image & histogram




stretching image and histogram






Equalization image and histogram
 

<gist>

</gist>


tags:
equalizeHist, cvtColor, normalize, calcHist

1/12/2018

python list, numpy slicing

Oh.. I seem to be old.. I need a memo everything..
This is memo for me about list slicing.

nums = list(range(5))
print(nums)      #[0, 1, 2, 3, 4]
print(nums[2:4]) #[2, 3]
print(nums[2:])  #[2, 3, 4] 
print(nums[:2])  #[0, 1]
print(nums[:])   #[0, 1, 2, 3, 4]
print(nums[:-1]) #[0, 1, 2, 3]
nums[2:4] = [8,9]
print(nums)      #[0, 1, 8, 9, 4]

result
[0, 1, 2, 3, 4]
[2, 3]
[2, 3, 4]
[0, 1]
[0, 1, 2, 3, 4]
[0, 1, 2, 3]
[0, 1, 8, 9, 4]


numpy slicing
import numpy as np

a = np.array([1, 2, 3, 4, 5])
print(a[1:3]) #array [2 3]
print(a[-1]) #5
a[0:2] = 9
print(a) #array [9 9 3 4 5]
b = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
print(b)
#array
#[[ 1  2  3  4]
# [ 5  6  7  8]
# [ 9 10 11 12]]

print(b[:,1]) #array [2 6 10]
print(b[-1])      #array [9 10 11 12]
print(b[-1,:])    #array [9 10 11 12]
print(b[-1, ...]) #array [9 10 11 12]

print(b[0:2, :])
#array#[[1 2 3 4]# [5 6 7 8]]
😀