Apply filter to a FastBitmap.
342562
@Override
    public ImageSource apply(ImageSource fastBitmap) {
        Convolution c = new Convolution(kernel);
        return c.apply(fastBitmap);
    }
1013746
def apply_filters prev_filters = nil, filter_codecs = nil
      prev_filters = filter_types if prev_filters.nil?
      filter_codecs = [] if filter_codecs.nil?
      current_filters = []
      prev = nil
      line_sizes = []
      scanline_positions.push(@filtered_data.size).inject do |m, n|
        line_sizes << n - m - 1
        n
      end
      wrap_with_rewind(@filtered_data) do
        # decode all scanlines
        prev_filters.each_with_index do |type, i|
          byte = @filtered_data.read 1
          current_filters << byte.unpack('C').first
          line_size = line_sizes[i]
          line = @filtered_data.read line_size
          filter = Filter.new type, @sample_size
          if filter_codecs[i] && filter_codecs[i][:decoder]
            filter.decoder = filter_codecs[i][:decoder]
          end
          if !prev.nil? && @interlace_pass_count.include?(i + 1)  # make sure prev to be nil if interlace pass is changed
            prev = nil
          end
          decoded = filter.decode line, prev
          @filtered_data.pos -= line_size
          @filtered_data << decoded
          prev = decoded
        end
        # encode all
        filter_codecs.reverse!
        line_sizes.reverse!
        data_amount = @filtered_data.pos # should be eof
        ref = data_amount
        current_filters.reverse_each.with_index do |type, i|
          line_size = line_sizes[i]
          ref -= line_size + 1
          @filtered_data.pos = ref + 1
          line = @filtered_data.read line_size
          prev = nil
          if !line_sizes[i + 1].nil?
            @filtered_data.pos = ref - line_size
            prev = @filtered_data.read line_size
          end
          # make sure prev to be nil if interlace pass is changed
          if @interlace_pass_count.include?(current_filters.size - i)
            prev = nil
          end
          filter = Filter.new type, @sample_size
          if filter_codecs[i] && filter_codecs[i][:encoder]
            filter.encoder = filter_codecs[i][:encoder]
          end
          encoded = filter.encode line, prev
          @filtered_data.pos = ref + 1
          @filtered_data << encoded
        end
      end
    end
724200
def OnInsertBitmap(self, event):
        """"""

        key = self.grid.actions.cursor
        # Get file name

        wildcard = _("Bitmap file") + " (*)|*"
        if rsvg is not None:
            wildcard += "|" + _("SVG file") + " (*.svg)|*.svg"

        message = _("Select image for current cell")
        style = wx.OPEN | wx.CHANGE_DIR
        filepath, index = \
            self.grid.interfaces.get_filepath_findex_from_user(wildcard,
                                                               message, style)
        if index == 0:
            # Bitmap loaded
            try:
                img = wx.EmptyImage(1, 1)
                img.LoadFile(filepath)
            except TypeError:
                return

            if img.GetSize() == (-1, -1):
                # Bitmap could not be read
                return

            code = self.grid.main_window.actions.img2code(key, img)

        elif index == 1 and rsvg is not None:
            # SVG loaded
            with open(filepath) as infile:
                try:
                    code = infile.read()
                except IOError:
                    return
                if is_svg(code):
                    code = 'u"""' + code + '"""'
                else:
                    # Does not seem to be an svg file
                    return

        else:
            code = None

        if code:
            self.grid.actions.set_code(key, code)
1011500
private static void returnBitmapInto(final Bitmap bitmap, final String path, final Object into) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                if (into != null && path != null && bitmap != null) {
                    if (into instanceof ImageView) {
                        Log.d(TAG, "return bitmap " + path + " into ImageView");
                        ((ImageView) into).setImageBitmap(bitmap);
                    } else if (into instanceof Callback) {
                        Log.d(TAG, "return bitmap " + path + " into Callback");
                        ((Callback) into).onBitmapLoaded(path, bitmap);
                    }
                }
            }
        });
    }
139524
public void Forward(ImageSource fastBitmap) {

        this.width = fastBitmap.getWidth();
        this.height = fastBitmap.getHeight();
        if (!isTransformed) {
            if (fastBitmap.isGrayscale()) {
                if (Tools.isPowerOf2(width) && Tools.isPowerOf2(height)) {
                    data = new double[height][width];
                    for (int i = 0; i < height; i++) {
                        for (int j = 0; j < width; j++) {
                            data[i][j] = Tools.Scale(0, 255, 0, 1, fastBitmap.getRGB(i, j));
                        }
                    }
                    DiscreteCosineTransform.Forward(data);
                    isTransformed = true;
                } else {
                    try {
                        throw new IllegalArgumentException("Image width and height should be power of 2.");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            } else {
                try {
                    throw new IllegalArgumentException("Only grayscale images are supported.");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
119673
def applyFilters(self, endpoint):
        """"""
        for filter_function in self.filter_functions:
            e = filter_function(endpoint)
            if e is not None:
                # Once one of the filters has returned an
                # endpoint, do not apply any more.
                return e

        return None
891791
def fill(framebuf, color):
        """"""
        if color:
            fill = 0xFF
        else:
            fill = 0x00
        for i in range(len(framebuf.buf)):
            framebuf.buf[i] = fill
514961
function partial(area) {
    var allFilter = null;

    for (var _len2 = arguments.length, filters = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
        filters[_key2 - 1] = arguments[_key2];
    }

    if (filters.length == 1 && typeof filters[0] === 'string') {
        allFilter = filter$1(filters[0]);
    } else {
        allFilter = merge$1(filters);
    }

    return function (bitmap, done) {
        var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

        allFilter(getBitmap(bitmap, area), function (newBitmap) {
            done(putBitmap(bitmap, newBitmap, area));
        }, opt);
    };
}
966995
def apply(self, img, factor=0, **params):
        
        return np.ascontiguousarray(np.rot90(img, factor))
914673
public void wrap(ImmutableRoaringBitmap r) {
    this.roaringBitmap = r;
    this.hs = 0;
    this.pos = (short) (this.roaringBitmap.highLowContainer.size() - 1);
    this.nextContainer();
  }
78041
function SpriteMaskFilter(sprite)
{
    var maskMatrix = new math.Matrix();

    AbstractFilter.call(this,
        fs.readFileSync(__dirname + '/spriteMaskFilter.vert', 'utf8'),
        fs.readFileSync(__dirname + '/spriteMaskFilter.frag', 'utf8'),
        {
            mask:           { type: 'sampler2D', value: sprite._texture },
            alpha:          { type: 'f', value: 1},
            otherMatrix:    { type: 'mat3', value: maskMatrix.toArray(true) }
        }
    );

    this.maskSprite = sprite;
    this.maskMatrix = maskMatrix;
}
968501
private void blur(Bitmap bkg, View view) {
        long startMs = System.currentTimeMillis();
        //define layout params to the previous imageView in order to match its parent
        mBlurredBackgroundLayoutParams = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT
        );

        //overlay used to build scaled preview and blur background
        Bitmap overlay = null;

        //evaluate top offset due to action bar, 0 if the actionBar should be blurred.
        int actionBarHeight;
        if (mBlurredActionBar) {
            actionBarHeight = 0;
        } else {
            actionBarHeight = getActionBarHeight();
        }

        //evaluate top offset due to status bar
        int statusBarHeight = 0;
        if ((mHoldingActivity.getWindow().getAttributes().flags
            & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0) {
            //not in fullscreen mode
            statusBarHeight = getStatusBarHeight();
        }

        // check if status bar is translucent to remove status bar offset in order to provide blur
        // on content bellow the status.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
            && isStatusBarTranslucent()) {
            statusBarHeight = 0;
        }

        final int topOffset = actionBarHeight + statusBarHeight;
        // evaluate bottom or right offset due to navigation bar.
        int bottomOffset = 0;
        int rightOffset = 0;
        final int navBarSize = getNavigationBarOffset();

        if (mHoldingActivity.getResources().getBoolean(R.bool.blur_dialog_has_bottom_navigation_bar)) {
            bottomOffset = navBarSize;
        } else {
            rightOffset = navBarSize;
        }

        //add offset to the source boundaries since we don't want to blur actionBar pixels
        Rect srcRect = new Rect(
            0,
            topOffset,
            bkg.getWidth() - rightOffset,
            bkg.getHeight() - bottomOffset
        );

        //in order to keep the same ratio as the one which will be used for rendering, also
        //add the offset to the overlay.
        double height = Math.ceil((view.getHeight() - topOffset - bottomOffset) / mDownScaleFactor);
        double width = Math.ceil(((view.getWidth() - rightOffset) * height
            / (view.getHeight() - topOffset - bottomOffset)));

        // Render script doesn't work with RGB_565
        if (mUseRenderScript) {
            overlay = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
        } else {
            overlay = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.RGB_565);
        }
        try {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
                || mHoldingActivity instanceof ActionBarActivity
                || mHoldingActivity instanceof AppCompatActivity) {
                //add offset as top margin since actionBar height must also considered when we display
                // the blurred background. Don't want to draw on the actionBar.
                mBlurredBackgroundLayoutParams.setMargins(0, actionBarHeight, 0, 0);
                mBlurredBackgroundLayoutParams.gravity = Gravity.TOP;
            }
        } catch (NoClassDefFoundError e) {
            // no dependency to appcompat, that means no additional top offset due to actionBar.
            mBlurredBackgroundLayoutParams.setMargins(0, 0, 0, 0);
        }
        //scale and draw background view on the canvas overlay
        Canvas canvas = new Canvas(overlay);
        Paint paint = new Paint();
        paint.setFlags(Paint.FILTER_BITMAP_FLAG);

        //build drawing destination boundaries
        final RectF destRect = new RectF(0, 0, overlay.getWidth(), overlay.getHeight());

        //draw background from source area in source background to the destination area on the overlay
        canvas.drawBitmap(bkg, srcRect, destRect, paint);

        //apply fast blur on overlay
        if (mUseRenderScript) {
            overlay = RenderScriptBlurHelper.doBlur(overlay, mBlurRadius, true, mHoldingActivity);
        } else {
            overlay = FastBlurHelper.doBlur(overlay, mBlurRadius, true);
        }
        if (mDebugEnable) {
            String blurTime = (System.currentTimeMillis() - startMs) + " ms";
            Log.d(TAG, "Blur method : " + (mUseRenderScript ? "RenderScript" : "FastBlur"));
            Log.d(TAG, "Radius : " + mBlurRadius);
            Log.d(TAG, "Down Scale Factor : " + mDownScaleFactor);
            Log.d(TAG, "Blurred achieved in : " + blurTime);
            Log.d(TAG, "Allocation : " + bkg.getRowBytes() + "ko (screen capture) + "
                + overlay.getRowBytes() + "ko (blurred bitmap)"
                + (!mUseRenderScript ? " + temp buff " + overlay.getRowBytes() + "ko." : "."));
            Rect bounds = new Rect();
            Canvas canvas1 = new Canvas(overlay);
            paint.setColor(Color.BLACK);
            paint.setAntiAlias(true);
            paint.setTextSize(20.0f);
            paint.getTextBounds(blurTime, 0, blurTime.length(), bounds);
            canvas1.drawText(blurTime, 2, bounds.height(), paint);
        }
        //set bitmap in an image view for final rendering
        mBlurredBackgroundView = new ImageView(mHoldingActivity);
        mBlurredBackgroundView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        mBlurredBackgroundView.setImageDrawable(new BitmapDrawable(mHoldingActivity.getResources(), overlay));
    }
164656
def fastqfilter(self):
        """"""
        printtime('Creating filtered .fastqfiles', self.start)
        # Create and start threads
        for i in range(self.cpus):
            # Send the threads to the appropriate destination function
            threads = Thread(target=self.filterfastq, args=())
            # Set the daemon to true - something to do with thread management
            threads.setDaemon(True)
            # Start the threading
            threads.start()
        for sample in self.runmetadata.samples:
            self.filterqueue.put(sample)
        self.filterqueue.join()
        # Print the metadata to file
        metadataprinter.MetadataPrinter(self)
427223
def _image_filter(self, filter=None, size=2):
        
        from numpy import isscalar
        from scipy.ndimage.filters import median_filter, uniform_filter

        FILTERS = {
            'median': median_filter,
            'uniform': uniform_filter
        }

        func = FILTERS[filter]

        mode = self.mode
        value_shape = self.value_shape
        ndims = len(value_shape)

        if ndims == 3 and isscalar(size) == 1:
            size = [size, size, size]

        if ndims == 3 and size[2] == 0:
            def filter_(im):
                if mode == 'spark':
                    im.setflags(write=True)
                else:
                    im = im.copy()
                for z in arange(0, value_shape[2]):
                    im[:, :, z] = func(im[:, :, z], size[0:2])
                return im
        else:
            filter_ = lambda x: func(x, size)

        return self.map(lambda v: filter_(v), value_shape=self.value_shape)
1353697
def _get_upsampling_filter(size):
    """"""
    factor = (size + 1) // 2
    if size % 2 == 1:
        center = factor - 1
    else:
        center = factor - 0.5
    og = np.ogrid[:size, :size]
    filter = (1 - abs(og[0] - center) / factor) * \
             (1 - abs(og[1] - center) / factor)
    return filter
87914
private void applyFilter(){
        filteredItems.clear();

        Filter<M> filter = getFilter();
        if(filter == null){
            filteredItems.addAll(items);
        }else{
            for (int i = 0; i < items.size(); i++) {
                M item = items.get(i);
                if(filter.filter(item, query)){
                    filteredItems.add(item);
                }
            }
        }

        onFiltered();
    }
71251
public void apply() {
		// see if the distortion class needs to be created again
		if( distorter == null ) {
			Class typeOut = output.getImageType().getImageClass();
			switch( input.getImageType().getFamily() ) {
				case GRAY:
					distorter = FactoryDistort.distortSB(cached, (InterpolatePixelS)interp, typeOut);
					break;

				case PLANAR:
					distorter = FactoryDistort.distortPL(cached, (InterpolatePixelS)interp, typeOut);
					break;

				case INTERLEAVED:
					distorter = FactoryDistort.distortIL(cached, (InterpolatePixelMB) interp, output.getImageType());
					break;

				default:
					throw new IllegalArgumentException("Unsupported image type");
			}
		}
		distorter.setModel(outputToInput);

		distorter.apply(input,output);
	}