Ivan Dimitrov 5082012 Filtering in g eneral Widespread Suitable for Dataflow Easily upgradable 211 Applying the filter To apply the filter on the current pixel you need to use his neighbor pixels ID: 459994
Download Presentation The PPT/PDF document "Image Filtering – Motion Blur" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Image Filtering – Motion Blur
Ivan
Dimitrov
508/2012Slide2
Filtering in g
eneral
Widespread
Suitable for Dataflow Easily upgradable
2/11Slide3
Applying the filter
To apply the filter on the current pixel, you need to use his neighbor pixels
2/10
3/11Slide4
Sequential implementation
for(
int
x = 0; x < w; x++) for(int y = 0; y < h; y++) {
double red = 0.0, green = 0.0, blue = 0.0; //multiply every value of the filter with corresponding image pixel
for(int filterX = 0;
filterX
<
filterWidth
;
filterX
++)
//filtering
for(int filterY = 0; filterY < filterHeight; filterY++) { int imageX = (x - filterWidth / 2 + filterX + w) % w; int imageY = (y - filterHeight / 2 + filterY + h) % h; red += image[imageX][imageY].r * filter[filterX][filterY]; // red channel green += image[imageX][imageY].g * filter[filterX][filterY]; // green channel blue += image[imageX][imageY].b * filter[filterX][filterY]; //blue channel } result[x][y].r = min(max(int(factor * red + bias), 0), 255); //result image result[x][y].g = min(max(int(factor * green + bias), 0), 255); result[x][y].b = min(max(int(factor * blue + bias), 0), 255); }
4/11Slide5
Maxeler implementation (1)
We need to use more than one element at a time
because of how filtering works.
So we need to use Maxeler’s built-in function for getting previous elements of the array:
DFEVar stream.offset(
DFEVar
src
,
int
offset)
;
5/11Slide6
Maxeler implementation
(2)
Due to the edge cases, we need to use the built-in counter function in
Maxeler:
DFEVar control.count.simpleCounter(64);
6/11Slide7
Maxeler implementation
(3)
class
BlurKernel extends Kernel { protected
BlurKernel(KernelParameters parameters) { super(parameters);
DFEVar inputImg1 = io.input("array1", dfeInt(32));
DFEVar
count =
control.count.simpleCounter
(64
);
DFEVar First1 = stream.offset(inputImg1, -513); ); DFEVar Last1 = stream.offset(inputImg1, 513); DFEVar inputImg2 = io.input("array2", dfeInt(32)); DFEVar First2 = stream.offset(inputImg2, -513);//picsize 512x512 DFEVar Last2 = stream.offset(inputImg2, 513); DFEVar inputImg3 = io.input("array3", dfeInt(32)); DFEVar First3 = stream.offset(inputImg3, -513); DFEVar Last3 = stream.offset(inputImg3, 513); 7/11Slide8
Maxeler implementation (4)
inputImg1 = (count>512) ? count<(512*512-512) ? ((First1 + Last1 + inputImg1) /3):0 : 0;
inputImg2
= (count>512) ? count<(512*512-512) ? (First2 + Last2 + inputImg2) /3 :0 :0;
inputImg3 = (count>512) ? count<(512*512-512) ? (First3 + Last3 + inputImg3) /3 :0:0; io.output
("outImage1", inputImg1, inputImg1.getType()); io.output("outImage2", inputImg2, inputImg2.getType()); io.output
("outImage3", inputImg3, inputImg3.getType());
}
}
8/11Slide9
Output
9/11Slide10
Application
10/11
Image filtering is broadly used in web applications, social networks, chat applications…
AWS will soon rent servers with
M
axeler
cards
Social networks and other web applications can use
M
axeler
servers to process their images and save a lot of energy and timeSlide11
References
[1]
Image Processing in
C, Dwayne Phillips, 1994[2] Guide to DataFlow
SuperComputing, V. Milutinovic, J. Salom, N.
Trifunovic, R. Giorgi, 2015[3]
Blur Motion,
https
://
en.wikipedia.org/wiki/Motion_blur
, 1.1.2016
11/11Slide12
Q&A