import argparse
import pandas as pd
import skimage.io
import skimage.color

def get_pixel_values(im, threshold, pixel_table, white_obj):
    data = skimage.io.imread(im)
    if len(data.shape) == 3 and data.shape[-1] > 1:
        data = skimage.color.rgb2grey(data)
    x = []
    y = []
    for i in range(data.shape[0]):
        for j in range(data.shape[1]):
            if white_obj == True:
                if data[j,i] <= threshold:
                    x.append(i)
                    y.append(j)
            elif data[j,i] >= threshold:
                    x.append(i)
                    y.append(j)
                    
    df = pd.DataFrame()
    df['x'] = x
    df['y'] = y    
    df.to_csv(pixel_table, sep="\t", index = False)
                     
if __name__=="__main__":
    parser = argparse.ArgumentParser(description = "Create a csv table with Coordinates of the ROI")
    parser.add_argument("im", help = "Paste path to out.png (output created by transformation)")
    parser.add_argument("pixel_table", help = "Paste path to file in which list with all pixles > threshold should be saved")
    parser.add_argument("--white_obj", dest = "white_obj", help = "If set objects in image are white otherwise black", action = "store_true", default=True)
    parser.add_argument("--threshold", dest = "threshold", help = "Enter desired threshold value", type = float, default = 0.5)
    args = parser.parse_args()    
    get_pixel_values(args.im, args.threshold, args.pixel_table, args.white_obj)     

@@ -71,16 +71,33 @@
 e.color%0D
+%0Aimport warnings%0D
 %0A%0D%0Adef g
@@ -119,19 +119,8 @@
 (im,
- threshold,
  pix
@@ -138,16 +138,41 @@
 hite_obj
+, threshold, offset=%5B0,0%5D
 ):%0D%0A    
@@ -427,19 +427,20 @@
 _obj == 
-Tru
+Fals
 e:%0D%0A    
@@ -459,19 +459,19 @@
 if data%5B
-j,i
+i,j
 %5D %3C= thr
@@ -500,33 +500,45 @@
        x.append(
-i
+j + offset%5B0%5D
 )%0D%0A             
@@ -545,33 +545,45 @@
        y.append(
-j
+i + offset%5B1%5D
 )%0D%0A            e
@@ -595,11 +595,11 @@
 ata%5B
-j,i
+i,j
 %5D %3E=
@@ -640,17 +640,29 @@
 .append(
-i
+j + offset%5B0%5D
 )%0D%0A     
@@ -685,17 +685,29 @@
 .append(
-j
+i + offset%5B1%5D
 )%0D%0A     
@@ -780,20 +780,16 @@
 'y'%5D = y
-    
 %0D%0A    df
@@ -1207,24 +1207,217 @@
 be saved%22)%0D%0A
+    parser.add_argument('offset_x', type=int, help='offset in x direction (width)', default=0)%0D%0A    parser.add_argument('offset_y', type=int, help='offset in y direction (height)', default=0)%0D%0A
     parser.a
@@ -1462,16 +1462,31 @@
 te_obj%22,
+ default=False,
  help = 
@@ -1563,22 +1563,8 @@
 rue%22
-, default=True
 )%0D%0A 
@@ -1620,16 +1620,31 @@
 eshold%22,
+ default = 0.5,
  help = 
@@ -1692,24 +1692,15 @@
 loat
-, default = 0.5)
+)%0D%0A    
 %0D%0A  
@@ -1729,17 +1729,95 @@
 args()  
- 
+%0D%0A    # with warnings.catch_warnings():%0D%0A%09#     warnings.simplefilter(%22ignore%22)
  %0D%0A    g
@@ -1840,16 +1840,50 @@
 args.im,
+ args.pixel_table, args.white_obj,
  args.th
@@ -1895,40 +1895,38 @@
 ld, 
+%5B
 args.
-pixel_table, args.white_obj
+offset_x, args.offset_y%5D
 )   

change x and y, introduce offset