public BufferedImage aplicaFiltro(BufferedImage bi) { // BufferedImage image = ImageIO.read(new File("c:/images.jpg")); BufferedImage image2; try { blur.setValor(blurVal); bi = blur.aplicaFiltro(bi); image2 = ImageIO.read(new File("imagens/glaucoma.png")); int w = (image2.getWidth() / 100) * size; int h = (image2.getHeight() / 100) * size; // calcular o centro int x = (bi.getWidth() / 2) - (w / 2); int y = (bi.getHeight() / 2) - (h / 2); Graphics2D graphics = bi.createGraphics(); graphics.drawImage(image2, x, y, w, h, null); graphics.dispose(); return bi; } catch (IOException e) { e.printStackTrace(); } return bi; }
public void onto(final ViewGroup target) { factor.width = target.getMeasuredWidth(); factor.height = target.getMeasuredHeight(); if (async) { BlurTask task = new BlurTask( target, factor, new BlurTask.Callback() { @Override public void done(BitmapDrawable drawable) { addView(target, drawable); } }); task.execute(); } else { Drawable drawable = new BitmapDrawable(context.getResources(), Blur.rs(target, factor)); addView(target, drawable); } }
public void into(final ImageView target) { factor.width = capture.getMeasuredWidth(); factor.height = capture.getMeasuredHeight(); if (async) { BlurTask task = new BlurTask( capture, factor, new BlurTask.Callback() { @Override public void done(BitmapDrawable drawable) { target.setImageDrawable(drawable); } }); task.execute(); } else { Drawable drawable = new BitmapDrawable(context.getResources(), Blur.rs(capture, factor)); target.setImageDrawable(drawable); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); gifImageView = (GifImageView) findViewById(R.id.gifImageView); btnToggle = (Button) findViewById(R.id.btnToggle); btnBlur = (Button) findViewById(R.id.btnBlur); final Button btnClear = (Button) findViewById(R.id.btnClear); blur = Blur.newInstance(this); gifImageView.setOnFrameAvailableListener( new GifImageView.OnFrameAvailableListener() { @Override public Bitmap onFrameAvailable(Bitmap bitmap) { if (shouldBlur) { return blur.blur(bitmap); } return bitmap; } }); btnToggle.setOnClickListener(this); btnClear.setOnClickListener(this); btnBlur.setOnClickListener(this); new GifDataDownloader() { @Override protected void onPostExecute(final byte[] bytes) { gifImageView.setBytes(bytes); gifImageView.startAnimation(); Log.d(TAG, "GIF width is " + gifImageView.getGifWidth()); Log.d(TAG, "GIF height is " + gifImageView.getGifHeight()); } }.execute("http://katemobile.ru/tmp/sample3.gif"); }
public ShapesDataStructure accumulate_n_blur( BigInteger[][] enc_img, int rho_step, double theta_step, BigInteger nsquare, BigInteger enc_0) { BigInteger[][] rho_theta_space = accumulate(enc_img, rho_step, theta_step, nsquare, enc_0); // int w=enc_img.length; // int h=enc_img[0].length; long start_blurring = System.currentTimeMillis(); Blur b = new Blur(); b.setKernel_multiplier(kernel_multiplier); BigInteger blurred[][] = b.filter(rho_theta_space, nsquare, enc_0); long stop_blurring = System.currentTimeMillis(); System.out.println( "HOUGH blurring (with a kernel of radius 2) time(ms): " + (stop_blurring - start_blurring)); // calculate the differences and put them in the data structure // the idea is to use blurring for some points and the original for other points // in such a way to hinder the jig-saw attacks System.out.println( "HOUGH calculating differences radius_rho= " + rho_radius + " ,radius_theta= " + theta_radius); BigInteger minusOne = new BigInteger("-1"); int ws = rho_theta_space.length; int hs = rho_theta_space[0].length; // preparing the data structure for storing the differences long start_preparating_differences = System.currentTimeMillis(); BigInteger[][] points_differences = new BigInteger[ws * hs][((2 * rho_radius + 1) * (2 * theta_radius + 1)) - 1]; Point points[] = new Point[ws * hs]; long stop_preparating_differences = System.currentTimeMillis(); System.out.println( "HOUGH preparating data structure for differences, time(ms): " + (stop_preparating_differences - start_preparating_differences)); // for (int x=0; x<rho_theta_space.length; x++) // for (int y=0; y<rho_theta_space[0].length; y++) // System.out.println(rho_theta_space[x][y]); long start_calculating_differences = System.currentTimeMillis(); int count = 0; for (int i = 0; i < ws; i++) for (int j = 0; j < hs; j++) { Point point = new Point(i, j, rho_theta_space[i][j]); points[count] = point; // size = (2*rho_radius+1)*(2*theta_radius+1)-1); if ((i + j) % 2 == 0) { int counta = 0; for (int i1 = i - rho_radius; i1 < i + rho_radius + 1; i1++) for (int j1 = j - theta_radius; j1 < j + theta_radius + 1; j1++) if (i1 >= 0 && i1 < ws && j1 >= 0 && j1 < hs && !(i1 == i && j1 == j)) { // differences.append( rho_theta_space[i][j]-rho_theta_space[i1][j1]); if (!blurred[i1][j1].equals(blurred[i][j])) { BigInteger c = blurred[i1][j1].modPow(minusOne, nsquare); points_differences[count][counta] = blurred[i][j].multiply(c).mod(nsquare); // System.out.println(points_differences[count][counta]);//==BigInteger.ONE){ } // System.out.println(ws); // System.out.println(hs); // System.out.println(points_differences[count][counta]);//==BigInteger.ONE){ // System.out.println(i+" "+j+" "+rho_theta_space[i][j]); // System.out.println(i1+" "+j1+" "+rho_theta_space[i1][j1]); // System.out.println(); // } counta++; } } else { int counta = 0; for (int i1 = i - rho_radius; i1 < i + rho_radius + 1; i1++) for (int j1 = j - theta_radius; j1 < j + theta_radius + 1; j1++) if (i1 >= 0 && i1 < ws && j1 >= 0 && j1 < hs && !(i1 == i && j1 == j)) { // differences.append( rho_theta_space[i][j]-rho_theta_space[i1][j1]); if (!rho_theta_space[i1][j1].equals(rho_theta_space[i][j])) { BigInteger c = rho_theta_space[i1][j1].modPow(minusOne, nsquare); points_differences[count][counta] = rho_theta_space[i][j].multiply(c).mod(nsquare); // System.out.println(points_differences[count][counta]); } counta++; } } // for (BigInteger g: points_differences[count]) // if (g!=null) // System.out.println(g); count++; // points_differences.put(p, differences); } long stop_calculating_differences = System.currentTimeMillis(); System.out.println( "HOUGH calculating differences done, time(ms): " + (stop_calculating_differences - start_calculating_differences)); return new ShapesDataStructure(points, points_differences); }