add invert flag
This commit is contained in:
parent
946b1f255d
commit
1e6036cde4
|
@ -11,9 +11,10 @@ parser.add_argument('filename') # positional argument
|
||||||
parser.add_argument('-o', '--output') # option that takes a value
|
parser.add_argument('-o', '--output') # option that takes a value
|
||||||
parser.add_argument('-f', '--format', choices=['firmware','nodered','nodered_int'], default='firmware', help='Output format') # option that takes a value
|
parser.add_argument('-f', '--format', choices=['firmware','nodered','nodered_int'], default='firmware', help='Output format') # option that takes a value
|
||||||
parser.add_argument('-v', '--verbose', action='store_true') # on/off flag
|
parser.add_argument('-v', '--verbose', action='store_true') # on/off flag
|
||||||
|
parser.add_argument('-i', '--invert', action='store_true')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
print(args.filename, args.output, args.format,args.verbose)
|
print(args.filename, args.output, args.format,args.verbose,args.invert)
|
||||||
|
|
||||||
|
|
||||||
im = Image.open(args.filename) # Can be many different formats.
|
im = Image.open(args.filename) # Can be many different formats.
|
||||||
|
@ -73,6 +74,9 @@ with open('result.txt', 'w') as f:
|
||||||
columnValue=0
|
columnValue=0
|
||||||
for y in reversed(range(im.size[1])):
|
for y in reversed(range(im.size[1])):
|
||||||
c = pix[x,y] #get pixel
|
c = pix[x,y] #get pixel
|
||||||
|
if args.invert:
|
||||||
|
c=255-c
|
||||||
|
|
||||||
if (c[0]>127):
|
if (c[0]>127):
|
||||||
if output_col_write_binary_flag:
|
if output_col_write_binary_flag:
|
||||||
f.write("1")
|
f.write("1")
|
||||||
|
|
Loading…
Reference in New Issue