A single line describing this image
963098
def display_line(self):
        """"""
        msg = ["Image {0}".format(self.name)]
        if self.image_index:
            msg.append("Pushes to {0}".format(self.image_name))
        return ' : '.join(msg)
1209389
def image(self, image):
        
        if image.mode != '1':
            raise ValueError('Image must be in mode 1.')
        imwidth, imheight = image.size
        if imwidth != self.width or imheight != self.height:
            raise ValueError('Image must be same dimensions as display ({0}x{1}).' \
                .format(self.width, self.height))
        # Grab all the pixels from the image, faster than getpixel.
        pix = image.load()
        # Iterate through the memory pages
        index = 0
        for page in range(self._pages):
            # Iterate through all x axis columns.
            for x in range(self.width):
                # Set the bits for the column of pixels at the current position.
                bits = 0
                # Don't use range here as it's a bit slow
                for bit in [0, 1, 2, 3, 4, 5, 6, 7]:
                    bits = bits << 1
                    bits |= 0 if pix[(x, page*8+7-bit)] == 0 else 1
                # Update buffer byte and increment to next byte.
                self._buffer[index] = bits
                index += 1
124080
def _filter_scanline(self, filter_type, line, result):
        
        assert 0 <= filter_type < 5
        if self.prev is None:
            # We're on the first line.  Some of the filters can be reduced
            # to simpler cases which makes handling the line "off the top"
            # of the image simpler.  "up" becomes "none"; "paeth" becomes
            # "left" (non-trivial, but true). "average" needs to be handled
            # specially.
            if filter_type == 2:  # "up"
                filter_type = 0
            elif filter_type == 3:
                self.prev = newBarray(len(line))
            elif filter_type == 4:  # "paeth"
                filter_type = 1

        if filter_type == 1:
            self.__do_filter_sub(line, result)
        elif filter_type == 2:
            self.__do_filter_up(line, result)
        elif filter_type == 3:
            self.__do_filter_average(line, result)
        elif filter_type == 4:
            self.__do_filter_paeth(line, result)
1358133
def vis(bs):
    
    bs = bytearray(bs)
    symbols_in_one_line = 8
    n = len(bs) // symbols_in_one_line
    i = 0
    for i in range(n):
        print(str(i*symbols_in_one_line)+" | "+" ".join(["%02X" % b for b in bs[i*symbols_in_one_line:(i+1)*symbols_in_one_line]])) # for every 8 symbols line
    if not len(bs) % symbols_in_one_line == 0:
        print(str((i+1)*symbols_in_one_line)+" | "+" ".join(["%02X" % b for b in bs[(i+1)*symbols_in_one_line:]])+"\n")
6913
def linetoraster(m):
    

    # Assumes monospaced font.
    x = 8 * len(m)
    y = 8
    return x, y, [itertools.chain(*row) for row in zip(*map(char, m))]
427887
def img(self):
        ''''''
        if self._img is not None:
            return self._img 
        self._img = cv2.cvtColor(self.original_img, cv2.COLOR_BGR2RGB)
        if self.border_width and self.border_colour is not None:
            cv2.rectangle(self._img, (0, 0), (self.width-1, self.height-1),
                          self.border_colour, self.border_width)
        return self._img
1226675
def visual(title, X, activation):
    '''
    '''
    assert len(X.shape) == 4

    X = X.transpose((0, 2, 3, 1))
    if activation == 'sigmoid':
        X = np.clip((X)*(255.0), 0, 255).astype(np.uint8)
    elif activation == 'tanh':
        X = np.clip((X+1.0)*(255.0/2.0), 0, 255).astype(np.uint8)
    n = np.ceil(np.sqrt(X.shape[0]))
    buff = np.zeros((int(n*X.shape[1]), int(n*X.shape[2]), int(X.shape[3])), dtype=np.uint8)
    for i, img in enumerate(X):
        fill_buf(buff, i, img, X.shape[1:3])
    cv2.imwrite('%s.jpg' % (title), buff)
761766
protected function drawLine()
    {
        $lineColor = imagecolorallocate($this->image, mt_rand(50, 255), mt_rand(100, 255), mt_rand(0, 255));

        for($i = 0; $i < $this->lines; $i++)
        {
            imageline($this->image, 0, mt_rand() % $this->height, $this->width, mt_rand() % $this->height, $lineColor);
        }
    }
1351741
def line(coord, draw)
      line_xy(coord.x1, coord.y1, coord.x2, coord.y2, draw)
    end
253379
def description_of(lines, name='stdin'):
    
    u = UniversalDetector()
    for line in lines:
        u.feed(line)
    u.close()
    result = u.result
    if result['encoding']:
        return '{0}: {1} with confidence {2}'.format(name, result['encoding'],
                                                     result['confidence'])
    else:
        return '{0}: no result'.format(name)
726826
def ReadTif(tifFile):
        """"""
        img = Image.open(tifFile)
        img = np.array(img)
        return img
858776
def _draw_line(self, line, isheader=False):
        

        line = self._splitit(line, isheader)
        space = " "
        out  = ""
        for i in range(len(line[0])):
            if self._has_border():
                out += "%s " % self._char_vert
            length = 0
            for cell, width, align in zip(line, self._width, self._align):
                length += 1
                cell_line = cell[i]
                fill = width - len(cell_line)
                if isheader:
                    align = "c"
                if align == "r":
                    out += "%s " % (fill * space + cell_line)
                elif align == "c":
                    out += "%s " % (fill/2 * space + cell_line \
                            + (fill/2 + fill%2) * space)
                else:
                    out += "%s " % (cell_line + fill * space)
                if length < len(line):
                    out += "%s " % [space, self._char_vert][self._has_vlines()]
            out += "%s\n" % ['', self._char_vert][self._has_border()]
        return out
1007329
private static <T extends ImageGray<T>, FD extends TupleDesc>
	void describeImage(T image,
					   DetectDescribePoint<T,FD> detDesc,
					   List<Point2D_F64> points,
					   FastQueue<FD> listDescs) {
		detDesc.detect(image);

		listDescs.reset();
		for( int i = 0; i < detDesc.getNumberOfFeatures(); i++ ) {
			points.add( detDesc.getLocation(i).copy() );
			listDescs.grow().setTo(detDesc.getDescription(i));
		}
	}
1066228
def display(self, image):
        
        assert(image.mode == self.mode)
        assert(image.size == self.size)

        image = self.preprocess(image)

        self.command(0x20, 0x80, 0x40)

        buf = bytearray(self._w * self._h // 8)
        off = self._offsets
        mask = self._mask

        for idx, pix in enumerate(image.getdata()):
            if pix > 0:
                buf[off[idx]] |= mask[idx]

        self.data(list(buf))
467895
def drawQuad(self, img=None, quad=None, thickness=30):
        '''
         
        '''
        if img is None:
            img = self.img
        if quad is None:
            quad = self.quad
        q = np.int32(quad)
        c = int(img.max())
        cv2.line(img, tuple(q[0]), tuple(q[1]), c, thickness)
        cv2.line(img, tuple(q[1]), tuple(q[2]), c, thickness)
        cv2.line(img, tuple(q[2]), tuple(q[3]), c, thickness)
        cv2.line(img, tuple(q[3]), tuple(q[0]), c, thickness)
        return img
238587
def linePlot(img, x0, y0, x1, y1, resolution=None, order=3):
    '''
    
    '''
    if resolution is None:
        resolution = int( ((x1-x0)**2 + (y1-y0)**2 )**0.5 )
    
    if order == 0:
        x = np.linspace(x0, x1, resolution, dtype=int)
        y = np.linspace(y0, y1, resolution, dtype=int)
        return img[y, x]

    x = np.linspace(x0, x1, resolution)
    y = np.linspace(y0, y1, resolution)
    return map_coordinates(img, np.vstack((y,x)), order=order)
189885
private ImageDeskew.HoughLine[] getTop(int count) {

        ImageDeskew.HoughLine[] hl = new ImageDeskew.HoughLine[count];
        for (int i = 0; i < count; i++) {
            hl[i] = new ImageDeskew.HoughLine();
        }

        ImageDeskew.HoughLine tmp;

        for (int i = 0; i < (this.cHMatrix.length - 1); i++) {
            if (this.cHMatrix[i] > hl[count - 1].count) {
                hl[count - 1].count = this.cHMatrix[i];
                hl[count - 1].index = i;
                int j = count - 1;
                while ((j > 0) && (hl[j].count > hl[j - 1].count)) {
                    tmp = hl[j];
                    hl[j] = hl[j - 1];
                    hl[j - 1] = tmp;
                    j--;
                }
            }
        }

        int alphaIndex;
        int dIndex;
        
        for (int i = 0; i < count; i++) {
            dIndex = hl[i].index / cSteps; // integer division, no
            // remainder
            alphaIndex = hl[i].index - dIndex * cSteps;
            hl[i].alpha = getAlpha(alphaIndex);
            hl[i].d = dIndex + cDMin;
        }

        return hl;
    }