diff --git a/_posts/2011-10-18-activate-numpad-on-startup.markdown b/_posts/2011-10-18-activate-numpad-on-startup.markdown
index 2b2fa6c..a89d230 100644
--- a/_posts/2011-10-18-activate-numpad-on-startup.markdown
+++ b/_posts/2011-10-18-activate-numpad-on-startup.markdown
@@ -82,8 +82,8 @@ To run on startup, this module had to be added to the list of apps to be started
On my Openbox based Crunchbang, the solution was to edit my autostart.sh to add a new line :
[bash]
-$ echo "(sleep 5s && numlock) &" \
->> ~/.config/openbox/autostart.sh
+$ echo "(sleep 5s && numlock) &" \
+>> ~/.config/openbox/autostart.sh
[/bash]
That's all !
diff --git a/_posts/2011-10-27-opencv-rect-expects-four-integers.markdown b/_posts/2011-10-27-opencv-rect-expects-four-integers.markdown
index 6a61ecc..be2b3e8 100644
--- a/_posts/2011-10-27-opencv-rect-expects-four-integers.markdown
+++ b/_posts/2011-10-27-opencv-rect-expects-four-integers.markdown
@@ -29,7 +29,7 @@ Here is an example :
import cv
-img = cv.LoadImage("test.jpg")
+img = cv.LoadImage("test.jpg")
dims = cv.GetSize(img)
roi = [0, 0, dims[0] / 2, dims[1] / 2 ]
cv.SetImageROI(img, roi)
@@ -39,7 +39,7 @@ You will get this result:
[python]
Traceback (most recent call last):
- File "newfile.py", line 8, in <module>
+ File "newfile.py", line 8, in
cv.SetImageROI(img, roi)
TypeError: CvRect argument 'rect' expects four integers
[/python]
diff --git a/_posts/2011-11-28-simple-region-growing-implementation-in-python.markdown b/_posts/2011-11-28-simple-region-growing-implementation-in-python.markdown
index 5a48c99..e3335ab 100644
--- a/_posts/2011-11-28-simple-region-growing-implementation-in-python.markdown
+++ b/_posts/2011-11-28-simple-region-growing-implementation-in-python.markdown
@@ -208,38 +208,38 @@ import cv
import numpy
def simple_region_growing(img, seed, threshold=1):
- """
+ """
A (very) simple implementation of region growing.
Extracts a region of the input image depending on a start position and a stop condition.
The input should be a single channel 8 bits image and the seed a pixel position (x, y).
The threshold corresponds to the difference between outside pixel intensity and mean intensity of region.
In case no new pixel is found, the growing stops.
Outputs a single channel 8 bits binary (0 or 255) image. Extracted region is highlighted in white.
- """
+ """
try:
dims = cv.GetSize(img)
except TypeError:
- raise TypeError("(%s) img : IplImage expected!" % (sys._getframe().f_code.co_name))
+ raise TypeError("(%s) img : IplImage expected!" % (sys._getframe().f_code.co_name))
# img test
if not(img.depth == cv.IPL_DEPTH_8U):
- raise TypeError("(%s) 8U image expected!" % (sys._getframe().f_code.co_name))
+ raise TypeError("(%s) 8U image expected!" % (sys._getframe().f_code.co_name))
elif not(img.nChannels is 1):
- raise TypeError("(%s) 1C image expected!" % (sys._getframe().f_code.co_name))
+ raise TypeError("(%s) 1C image expected!" % (sys._getframe().f_code.co_name))
# threshold tests
if (not isinstance(threshold, int)) :
- raise TypeError("(%s) Int expected!" % (sys._getframe().f_code.co_name))
- elif threshold < 0:
- raise ValueError("(%s) Positive value expected!" % (sys._getframe().f_code.co_name))
+ raise TypeError("(%s) Int expected!" % (sys._getframe().f_code.co_name))
+ elif threshold < 0:
+ raise ValueError("(%s) Positive value expected!" % (sys._getframe().f_code.co_name))
# seed tests
if not((isinstance(seed, tuple)) and (len(seed) is 2) ) :
- raise TypeError("(%s) (x, y) variable expected!" % (sys._getframe().f_code.co_name))
+ raise TypeError("(%s) (x, y) variable expected!" % (sys._getframe().f_code.co_name))
- if (seed[0] or seed[1] ) < 0 :
- raise ValueError("(%s) Seed should have positive values!" % (sys._getframe().f_code.co_name))
- elif ((seed[0] > dims[0]) or (seed[1] > dims[1])):
- raise ValueError("(%s) Seed values greater than img size!" % (sys._getframe().f_code.co_name))
+ if (seed[0] or seed[1] ) < 0 :
+ raise ValueError("(%s) Seed should have positive values!" % (sys._getframe().f_code.co_name))
+ elif ((seed[0] > dims[0]) or (seed[1] > dims[1])):
+ raise ValueError("(%s) Seed values greater than img size!" % (sys._getframe().f_code.co_name))
reg = cv.CreateImage( dims, cv.IPL_DEPTH_8U, 1)
cv.Zero(reg)
@@ -257,14 +257,14 @@ def simple_region_growing(img, seed, threshold=1):
cur_pix = [seed[0], seed[1]]
#Spreading
- while(dist<threshold and size<pix_area):
+ while(disttemp_pix[0]>0 and dims[1]>temp_pix[1]>0 #returns boolean
#candidate is taken if not already selected before
if (is_in_img and (reg[temp_pix[1], temp_pix[0]]==0)):
contour.append(temp_pix)
@@ -303,18 +303,18 @@ import tippy.display_operations as do
user_input = 0
-img_name = "tippy/data/gnu.jpg"
+img_name = "tippy/data/gnu.jpg"
threshold = 20
img = cv.LoadImage(img_name, cv.CV_LOAD_IMAGE_GRAYSCALE)
if user_input:
- seed = bo.mouse_point(img, mode="S") # waits for user click to get seed
+ seed = bo.mouse_point(img, mode="S") # waits for user click to get seed
else:
seed = (70, 106)
out_img = se.simple_region_growing(img, seed, threshold)
-do.display_single_image(out_img, "Region Growing result")
+do.display_single_image(out_img, "Region Growing result")
[/python]
As you can see, the implementation is rather short in code.
diff --git a/_posts/2011-12-02-pythonunittest-assertraises-raises-error.markdown b/_posts/2011-12-02-pythonunittest-assertraises-raises-error.markdown
index 40c2145..2995ff8 100644
--- a/_posts/2011-12-02-pythonunittest-assertraises-raises-error.markdown
+++ b/_posts/2011-12-02-pythonunittest-assertraises-raises-error.markdown
@@ -56,13 +56,13 @@ Let's say I want to create a (dum) function calculating the square value of a
[python]
def square_value(a):
- """
+ """
Returns the square value of a.
- """
+ """
try:
out = a*a
except TypeError:
- raise TypeError("Input should be a string:")
+ raise TypeError("Input should be a string:")
return out
[/python]
@@ -73,19 +73,19 @@ def square_value(a):
import dum_function as df # import function module
import unittest
class Test(unittest.TestCase):
- """
+ """
The class inherits from unittest
- """
+ """
def setUp(self):
- """
+ """
This method is called before each test
- """
- self.false_int = "A"
+ """
+ self.false_int = "A"
def tearDown(self):
- """
+ """
This method is called after each test
- """
+ """
pass
#---
## TESTS
@@ -93,7 +93,7 @@ class Test(unittest.TestCase):
# assertRaises(excClass, callableObj) prototype
self.assertRaises(TypeError, df.square_value(self.false_int))
-if __name__ == "__main__":
+if __name__ == "__main__":
unittest.main()
[/python]
@@ -104,10 +104,10 @@ if __name__ == "__main__":
ERROR: test_square_value (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
- File "test_dum_function.py", line 22, in test_square_value
+ File "test_dum_function.py", line 22, in test_square_value
self.assertRaises(TypeError, df.square_value(self.false_int))
- File "/home/jlengrand/Desktop/function.py", line 8, in square_value
- raise TypeError("Input should be a string:")
+ File "/home/jlengrand/Desktop/function.py", line 8, in square_value
+ raise TypeError("Input should be a string:")
TypeError: Input should be a string:
----------------------------------------------------------------------
diff --git a/_posts/2011-12-12-a-simple-way-to-get-a-multilingual-blog.markdown b/_posts/2011-12-12-a-simple-way-to-get-a-multilingual-blog.markdown
index 18d8870..93db05a 100644
--- a/_posts/2011-12-12-a-simple-way-to-get-a-multilingual-blog.markdown
+++ b/_posts/2011-12-12-a-simple-way-to-get-a-multilingual-blog.markdown
@@ -64,8 +64,8 @@ To do this, you need two things :
[javascript]
-<!-- Script créé par KevBrok ;-) -->
-<script type="text/javascript">// <![CDATA[
+
+
[/javascript]
@@ -140,14 +140,14 @@ To do this, you need two things :
Then, Write down your article in both languages, one after the other in you editor. Each language should be placed in a separate div; and a button placed to switch from one language to the other. Here is an example :
[javascript]
-<a href="javascript:InverseTout( 'mondiv' )">Français / English</a></pre>
-<div id="mondiv1" class="cachediv">
-<div style="border: 1px solid black; background-color: whitesmoke; margin-bottom: 2px;">My article in english</div>
-</div>
-<div id="mondiv2">
-<div style="border: 1px solid black; background-color: whitesmoke; margin-bottom: 2px;">Mon article en français</div>
-</div>
-<pre>
+
Français / English
+
+
+
Mon article en français
+
+
[/javascript]
diff --git a/_posts/2011-12-20-a-simple-way-to-watermark-a-batch-of-images.markdown b/_posts/2011-12-20-a-simple-way-to-watermark-a-batch-of-images.markdown
index 67e4603..35d027c 100644
--- a/_posts/2011-12-20-a-simple-way-to-watermark-a-batch-of-images.markdown
+++ b/_posts/2011-12-20-a-simple-way-to-watermark-a-batch-of-images.markdown
@@ -43,7 +43,7 @@ As a bonus, the script automatically detects whether an image is in landscape or
Here is an example of the result :
-[caption id="attachment_424" align="aligncenter" width="200" caption="picture of the "jardin des plantes" in Nantes"]
[/caption]
+[caption id="attachment_424" align="aligncenter" width="200" caption="picture of the "jardin des plantes" in Nantes"]
[/caption]
This script is in an early stage for now, and should be upgraded with time. You can check out the TODO list here.
diff --git a/_posts/2011-12-28-programming-tips-2.markdown b/_posts/2011-12-28-programming-tips-2.markdown
index 867ed1a..362297b 100644
--- a/_posts/2011-12-28-programming-tips-2.markdown
+++ b/_posts/2011-12-28-programming-tips-2.markdown
@@ -135,7 +135,7 @@ The command to search for is start-stop-daemon, with start opti
To avoid any output in stdout, use redirection:
[bash]
-$ command &> /dev/null&
+$ command &> /dev/null&
[/bash]
@@ -166,7 +166,7 @@ Simply add the line
[bash]
-trap " 2 3
+trap " 2 3
[/bash]
@@ -188,7 +188,7 @@ The operations can be performed with bc :
[bash]
-$ VAR=$(echo "2.2/ 10.65" | bc -l)
+$ VAR=$(echo "2.2/ 10.65" | bc -l)
[/bash]
@@ -206,7 +206,7 @@ $ (ceil) INT=${VAR/.*}
[bash]
-$ "find ./ -name .svn -prune -o -type f -print | xargs grep -Hi" //pattern//
+$ "find ./ -name .svn -prune -o -type f -print | xargs grep -Hi" //pattern//
[/bash]
@@ -239,7 +239,7 @@ Simply add a new line at the end of the file :
[bash]
-alias_name = "my_one_line_command"
+alias_name = "my_one_line_command"
[/bash]
@@ -251,7 +251,7 @@ Restart your terminal, you're done!
[bash]
-$ date -d "$FIRST_TIME" +"%s"
+$ date -d "$FIRST_TIME" +"%s"
[/bash]
@@ -261,7 +261,7 @@ $ date -d "$FIRST_TIME" +"%s"
[bash]
-$ which //language// > my_script
+$ which //language// > my_script
[/bash]
@@ -269,7 +269,7 @@ $ which //language// > my_script
[bash]
-$ which bash > my_script.sh
+$ which bash > my_script.sh
[/bash]
@@ -291,7 +291,7 @@ $ file -i //unkown_file_type//
$ cd //my_folder///
-$ find -name ".svn" -exec rm -rf {} \;
+$ find -name ".svn" -exec rm -rf {} \;
[/bash]
@@ -407,7 +407,7 @@ in your .bashrc. It can be done simply in running the followin
[bash]
-$ echo "complete -cf sudo" > ~/.bashrc
+$ echo "complete -cf sudo" > ~/.bashrc
[/bash]
@@ -533,7 +533,7 @@ file.open(file_name, 'a')
try:
print variable
except NameError:
- print "Error!"
+ print "Error!"
[/python]
@@ -563,9 +563,9 @@ a = b = c = 1+1
import sys
def tutut():
- """
+ """
Dum function displaying its name!
- """
+ """
print sys._getframe().f_code.co_name
if __name__ == '__main__':
@@ -613,13 +613,13 @@ with
About variables :
- - age -> value
- - &age -> pointer
+ - age -> value
+ - &age -> pointer
About pointers :
- - ptr -> ptr value(which is an address)
- - *ptr -> variable value placed in the address.
+ - ptr -> ptr value(which is an address)
+ - *ptr -> variable value placed in the address.
If age is a variable :