Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
x393
Commits
614bc659
Commit
614bc659
authored
Mar 29, 2019
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generating Verilog input data from tiff images
parent
cb75953f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
0 deletions
+94
-0
x393_tiff_verilog.py
py393/x393_tiff_verilog.py
+94
-0
No files found.
py393/x393_tiff_verilog.py
0 → 100644
View file @
614bc659
from
__future__
import
division
from
__future__
import
print_function
'''
# Copyright (C) 2015, Elphel.inc.
# Class to export hardware definitions from Verilog parameters
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
@author: Andrey Filippov
@copyright: 2015 Elphel, Inc.
@license: GPLv3.0+
@contact: andrey@elphel.com
@deffield updated: Updated
'''
__author__
=
"Andrey Filippov"
__copyright__
=
"Copyright 2015, Elphel, Inc."
__license__
=
"GPL"
__version__
=
"3.0+"
__maintainer__
=
"Andrey Filippov"
__email__
=
"andrey@elphel.com"
__status__
=
"Development"
from
PIL
import
Image
import
sys
import
numpy
as
np
class
imagej_tiff
:
# imagej stores labels lengths in this tag
__TIFF_TAG_LABELS_LENGTHS
=
50838
# imagej stores labels conents in this tag
__TIFF_TAG_LABELS_STRINGS
=
50839
# init
def
__init__
(
self
,
filename
,
digits
,
outname
):
# file name
self
.
fname
=
filename
self
.
outname
=
outname
tif
=
Image
.
open
(
filename
)
# total number of layers in tiff
# self.nimages = tif.n_frames
# labels array
# self.labels = []
# infos will contain xml data Elphel stores in some of tiff files
# self.infos = []
# dictionary from decoded infos[0] xml data
# self.props = {}
# bits per sample, type int
# self.bpp = tif.tag[258][0]
image_array
=
np
.
array
(
tif
)
f
=
"
%%0%
dx"
%
(
digits
)
with
open
(
outname
,
"w"
)
as
outfile
:
print
(
"//"
,
file
=
outfile
)
print
(
"// autogenerated from
%
s"
%
(
fname
),
file
=
outfile
)
print
(
"//"
,
file
=
outfile
)
for
image_line
in
image_array
:
for
pixel
in
image_line
:
print
(
f
%
(
pixel
),
file
=
outfile
,
end
=
" "
)
print
(
file
=
outfile
)
tif
.
close
()
#MAIN
if
__name__
==
"__main__"
:
try
:
fname
=
sys
.
argv
[
1
]
except
IndexError
:
fname
=
"/data_ssd/nc393/elphel393/fpga-elphel/x393/attic/hor-pairs-12b-1044x36.tiff"
try
:
digits
=
int
(
sys
.
argv
[
2
])
except
:
digits
=
3
try
:
outname
=
sys
.
argv
[
3
]
except
IndexError
:
outname
=
fname
.
replace
(
".tiff"
,
".vh"
)
ijt
=
imagej_tiff
(
fname
,
digits
,
outname
)
print
(
"All done!"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment