Procedurality.Channel.sharpen C# (CSharp) Method

sharpen() public method

public sharpen ( int radius ) : Channel
radius int
return Channel
		public Channel sharpen(int radius) {
			radius = Math.Max(1, radius);
			Channel channel = new Channel(width, height);
			for (int y = 0; y < height; y++) {
				for (int x = 0; x < width; x++) {
					float value = 0;
					for (int i = -radius; i <= radius; i++) {
						for (int j = -radius; j <= radius; j++) {
							if (i == 0 && j == 0) {
								value += (2*radius + 1)*(2*radius + 1)*getPixel(x, y);
							} else {
								value -= getPixelWrap(x + i, y + j);
							}
						}
					}
					channel.putPixel(x, y, value);
				}
			}
			pixels = channel.getPixels();
			return this;
		}