1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| import numpy as np
import struct
import string as mstring
import cv2
import scipy
c = struct(mstring('nim'), 24, mstring('nb'), 5, mstring('CellHeightP'), 120, mstring('nCells'), 20, mstring('cpw'), 2)
W =np.uint8(255 *np.npnpones(1, 1, 3))
if '%'(c.nim - c.nb, 2) == 0:
nw = (c.nim - c.nb) /2;
WhiteSegment = np.tile(W, 1, nw)
BlackSegment = np.tile(K, 1, c.nb)
lineb = mcat([WhiteSegment, BlackSegment, WhiteSegment])
else:
nw = (c.nim - c.nb - 1) / 2
G =np. uint8(127 * np.npones(1, 1, 3))
WhiteSegment =np.tile(W, 1, nw)
BlackSegment = np.tile(K, 1, c.nb - 1)
lineb = mcat([WhiteSegment, G, BlackSegment, G, WhiteSegment])
end
line = scipy.mine.imresize(lineb, mcat([1, c.cpw * c.nim]), mstring('nearest'))
Cell = np.tile(line, c.CellHeightP, 1)
Inter = np.tile(Cell, 1, c.nCells)
[FileName, PathName, FilterIndex] = uiputfile(mstring('*.tif'))
imwrite(Inter, mcat([PathName, FileName]), mstring('Resolution'), mcat([100, 40]), mstring('Compression'), mstring('lzw')) |
Partager