// Extract returns a grayscale image containing the values of the selected channel.
//
// Usage example:
//
//      result := channel.Extract(img, channel.Alpha)
//
556512
func Extract(img image.Image, c Channel) *image.Gray {
	if c < 0 || 3 < c {
		panic(fmt.Sprintf("channel index '%v' out of bounds. Red: 0, Green: 1, Blue: 2, Alpha: 3", c))
	}

	src := clone.AsRGBA(img)
	bounds := src.Bounds()
	srcW, srcH := bounds.Dx(), bounds.Dy()

	if bounds.Empty() {
		return &image.Gray{}
	}

	dst := image.NewGray(bounds)

	parallel.Line(srcH, func(start, end int) {
		for y := start; y < end; y++ {
			for x := 0; x < srcW; x++ {
				srcPos := y*src.Stride + x*4
				dstPos := y*dst.Stride + x

				dst.Pix[dstPos] = src.Pix[srcPos+int(c)]
			}
		}
	})

	return dst
}
227716
func (e *extractor) Extract(tarballPath string) (ExtractedStemcell, error) {
	tmpDir, err := e.fs.TempDir("stemcell-manager")
	if err != nil {
		return nil, bosherr.WrapError(err, "creating temp dir for stemcell extraction")
	}

	stemcell, err := e.reader.Read(tarballPath, tmpDir)
	if err != nil {
		_ = e.fs.RemoveAll(tmpDir)
		return nil, bosherr.WrapErrorf(err, "reading extracted stemcell manifest in '%s'", tmpDir)
	}

	return stemcell, nil
}
1178988
func (tsz *TarSz) Extract(source, target, destination string) error {
	tsz.wrapReader()
	return tsz.Tar.Extract(source, target, destination)
}
338641
func ExtractOffset(opts ...interface{}) *opt.OffsetOption {
	for _, o := range opts {
		if v, ok := o.(*opt.OffsetOption); ok {
			return v
		}
	}
	return nil
}
377411
func Extract(str string) ([][]byte, error) {
	m := re.FindAllString(str, -1)
	result := make([][]byte, 0, len(m))
	for _, s := range m {
		b, err := FromString(s)
		if err != nil {
			return nil, err
		}
		result = append(result, b)
	}
	return result, nil
}
417628
func (tlz4 *TarLz4) Extract(source, target, destination string) error {
	tlz4.wrapReader()
	return tlz4.Tar.Extract(source, target, destination)
}
796640
func (h HeaderBytes) extractHeaderAttribute(mask uint32) uint32 {

	data := binary.LittleEndian.Uint32(h)

	return data & mask
}
1322699
func Extractor(format interface{}, extractor jaeger.Extractor) Option {
	return func(c *Options) {
		c.extractors[format] = extractor
	}
}
1155665
func (t *Tracer) Extract(format, carrier interface{}) opentracing.SpanContext {
	sc, err := t.Tracer.Extract(format, carrier)
	if err != nil && err != opentracing.ErrSpanContextNotFound {
		t.logger.Debug("trace > ", err)
	}
	return sc
}
73825
func (txz *TarXz) Extract(source, target, destination string) error {
	txz.wrapReader()
	return txz.Tar.Extract(source, target, destination)
}
174012
func Extract(src string, dest string) error {
	mime, err := detect.Detect(src)

	if err != nil {
		return err
	}

	switch mime {
	case gzip.Type:
		err = gzip.Extract(src, dest)
	case zip.Type:
		err = zip.Extract(src, dest)
	case bz2.Type:
		err = bz2.Extract(src, dest)
	default:
		err = errors.New("Format is not supported")
	}

	if err != nil {
		return err
	}

	return nil
}
730033
func Extract(ctx context.Context) *logrus.Entry {
	l, ok := ctx.Value(ctxLoggerKey).(*ctxLogger)
	if !ok || l == nil {
		return logrus.NewEntry(nullLogger)
	}

	fields := logrus.Fields{}

	// Add grpc_ctxtags tags metadata until now.
	tags := grpc_ctxtags.Extract(ctx)
	for k, v := range tags.Values() {
		fields[k] = v
	}

	// Add logrus fields added until now.
	for k, v := range l.fields {
		fields[k] = v
	}

	return l.logger.WithFields(fields)
}
956229
func extractFile(gz []byte) (*protobuf.FileDescriptorProto, error) {
	r, err := gzip.NewReader(bytes.NewReader(gz))
	if err != nil {
		return nil, fmt.Errorf("failed to open gzip reader: %v", err)
	}
	defer r.Close()

	b, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, fmt.Errorf("failed to uncompress descriptor: %v", err)
	}

	fd := new(protobuf.FileDescriptorProto)
	if err := proto.Unmarshal(b, fd); err != nil {
		return nil, fmt.Errorf("malformed FileDescriptorProto: %v", err)
	}

	return fd, nil
}
894239
func (tgz *TarGz) Extract(source, target, destination string) error {
	tgz.wrapReader()
	return tgz.Tar.Extract(source, target, destination)
}
309348
func extract(dir string) error {

	// create dir if needed
	if _, err := os.Stat(dir); os.IsNotExist(err) {
		if err := os.MkdirAll(dir, 0777); err != nil {
			return err
		}
	}

	return unzip("apidocs_html.zip", dir)
}
710603
func (ext *Extractor) Extract(tokens []string) ([]Entity, error) {
	ctokens := C.ner_arr_make(C.int(len(tokens)) + 1) // NULL termination
	defer C.ner_arr_free(ctokens, C.int(len(tokens))+1)
	for i, t := range tokens {
		cs := C.CString(t) // released by ner_arr_free
		C.ner_arr_set(ctokens, cs, C.int(i))
	}

	dets := C.mitie_extract_entities(ext.ner, ctokens)
	defer C.mitie_free(unsafe.Pointer(dets))
	if dets == nil {
		return nil, ErrMemory
	}

	n := int(C.mitie_ner_get_num_detections(dets))
	entities := make([]Entity, n, n)

	for i := 0; i < n; i++ {
		pos := int(C.mitie_ner_get_detection_position(dets, C.ulong(i)))
		len := int(C.mitie_ner_get_detection_length(dets, C.ulong(i)))

		entities[i] = Entity{
			Tag:   int(C.mitie_ner_get_detection_tag(dets, C.ulong(i))),
			Score: float64(C.mitie_ner_get_detection_score(dets, C.ulong(i))),
			Name:  strings.Join(tokens[pos:pos+len], " "),
			Range: Range{pos, pos + len},
		}
	}
	return entities, nil
}
628637
func ExtractHeader(header string, resp *http.Response) []string {
	if resp != nil && resp.Header != nil {
		return resp.Header[http.CanonicalHeaderKey(header)]
	}
	return nil
}