└── BlurEffect ├── .idea ├── copyright │ └── profiles_settings.xml ├── description.html ├── vcs.xml ├── encodings.xml ├── modules.xml ├── compiler.xml ├── misc.xml ├── uiDesigner.xml └── workspace.xml ├── out └── production │ └── ImageBlur │ ├── Main.class │ ├── BlurEffect.class │ ├── FileUtil.class │ └── CoordinateCalc.class ├── src ├── Main.java ├── FileUtil.java ├── CoordinateCalc.java └── BlurEffect.java └── ImageBlur.iml /BlurEffect/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /BlurEffect/.idea/description.html: -------------------------------------------------------------------------------- 1 | Simple Java application that includes a class with main() method -------------------------------------------------------------------------------- /BlurEffect/out/production/ImageBlur/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yigang0622/GaussianBlur/HEAD/BlurEffect/out/production/ImageBlur/Main.class -------------------------------------------------------------------------------- /BlurEffect/out/production/ImageBlur/BlurEffect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yigang0622/GaussianBlur/HEAD/BlurEffect/out/production/ImageBlur/BlurEffect.class -------------------------------------------------------------------------------- /BlurEffect/out/production/ImageBlur/FileUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yigang0622/GaussianBlur/HEAD/BlurEffect/out/production/ImageBlur/FileUtil.class -------------------------------------------------------------------------------- /BlurEffect/out/production/ImageBlur/CoordinateCalc.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yigang0622/GaussianBlur/HEAD/BlurEffect/out/production/ImageBlur/CoordinateCalc.class -------------------------------------------------------------------------------- /BlurEffect/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BlurEffect/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BlurEffect/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BlurEffect/src/Main.java: -------------------------------------------------------------------------------- 1 | import java.awt.image.BufferedImage; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | BufferedImage img = FileUtil.loadImg("1.jpg"); 7 | assert img != null; 8 | System.out.println("Image Loaded: "+img.getWidth()+"x"+img.getHeight()); 9 | new BlurEffect(2,img).getBluredImg(); 10 | // 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BlurEffect/ImageBlur.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /BlurEffect/src/FileUtil.java: -------------------------------------------------------------------------------- 1 | import javax.imageio.ImageIO; 2 | import java.awt.image.BufferedImage; 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | /** 7 | * Created by mike on 3/27/16. 8 | */ 9 | public class FileUtil { 10 | 11 | public static BufferedImage loadImg(String fileName){ 12 | //String path = "/Users/Mike/Desktop/"; 13 | String path = "C:\\Users\\Mike\\Desktop\\"; 14 | File imgFile = new File(path+fileName); 15 | try { 16 | return ImageIO.read(imgFile); 17 | } catch (IOException e) { 18 | e.printStackTrace(); 19 | } 20 | return null; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /BlurEffect/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /BlurEffect/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /BlurEffect/src/CoordinateCalc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by mike on 3/28/16. 3 | */ 4 | 5 | //WARN: This class should not be used any more. 6 | public class CoordinateCalc { 7 | 8 | private int halfLength = 0; 9 | 10 | //QUADRANT Status Code 11 | static int QUADRANT_FIRST = 1; 12 | static int QUADRANT_SECOND = 2; 13 | static int QUADRANT_THIRD = 3; 14 | static int QUADRANT_FOURTH =4; 15 | static int QUADRANT_ON_X = 5; 16 | static int QUADRANT_ON_Y = 6; 17 | static int QUADRANT_ON_ORIGIN = 0; 18 | 19 | public CoordinateCalc(int length){ 20 | //Pass a odd number 21 | this.halfLength = (length-1)/2; 22 | System.out.println("Half Length: "+this.halfLength); 23 | } 24 | 25 | public int getX(int i, int j){ 26 | int quadrantCode = getQuadrant(i,j); 27 | 28 | switch (quadrantCode){ 29 | case 0: 30 | case 6: return 0; 31 | case 1: 32 | case 2: 33 | case 3: 34 | case 4: 35 | case 5: return j-halfLength; 36 | } 37 | return 0; 38 | } 39 | 40 | public int getY(int i, int j){ 41 | int quadrantCode = getQuadrant(i,j); 42 | switch (quadrantCode){ 43 | case 0: 44 | case 5: return 0; 45 | case 1: 46 | case 2: 47 | case 3: 48 | case 4: 49 | case 6: return halfLength-i; 50 | } 51 | return 0; 52 | } 53 | 54 | private int getQuadrant(int i,int j){ 55 | if ((i == halfLength) && (j==halfLength)){ 56 | return QUADRANT_ON_ORIGIN; 57 | }else if (i==halfLength && j!=halfLength){ 58 | return QUADRANT_ON_X; 59 | }else if (i!=halfLength && j==halfLength){ 60 | return QUADRANT_ON_Y; 61 | }else if (i<=halfLength && j>=halfLength){ 62 | return QUADRANT_FIRST; 63 | }else if (i<=halfLength-1 && j<=halfLength-1){ 64 | return QUADRANT_SECOND; 65 | }else if (i>halfLength && jhalfLength-1 && j>=halfLength-1){ 68 | return QUADRANT_FOURTH; 69 | } 70 | return 0; // This is not gonna happen 71 | } 72 | 73 | //Test Code 74 | public static void main(String[] args){ 75 | CoordinateCalc calc = new CoordinateCalc(5); 76 | 77 | for (int i=0;i<5;i++){ 78 | for (int j=0;j<5;j++ ){ 79 | System.out.print("("+calc.getX(i,j)+","+calc.getY(i,j)+") "); 80 | } 81 | System.out.println(); 82 | } 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /BlurEffect/src/BlurEffect.java: -------------------------------------------------------------------------------- 1 | import javax.imageio.ImageIO; 2 | import java.awt.*; 3 | import java.awt.image.BufferedImage; 4 | import java.io.File; 5 | import java.io.IOException; 6 | 7 | /** 8 | * Created by mike on 3/27/16. 9 | */ 10 | public class BlurEffect { 11 | 12 | private int blurRadius = 1; 13 | private BufferedImage image; 14 | private double[][] weightArr; 15 | 16 | public BlurEffect(int blurRadius,BufferedImage image){ 17 | this.blurRadius = blurRadius; 18 | this.image = image; 19 | weightArr = new double[blurRadius*2+1][blurRadius*2+1]; 20 | calculateWeightMatrix(); 21 | getFinalWeightMatrix(); 22 | } 23 | 24 | private double getR(int x,int y){ 25 | int rgb = image.getRGB(x, y); 26 | int r = (rgb & 0xff0000) >> 16; 27 | return r; 28 | } 29 | 30 | private double getG(int x,int y){ 31 | int rgb = image.getRGB(x, y); 32 | int g = (rgb & 0xff00) >> 8; 33 | return g; 34 | } 35 | 36 | private double getB(int x,int y){ 37 | int rgb = image.getRGB(x, y); 38 | int b = (rgb & 0xff); 39 | return b; 40 | } 41 | 42 | private double[][] getColorMatrix(int x, int y, int whichColor){ 43 | 44 | int startX = x-blurRadius; 45 | int startY = y-blurRadius; 46 | int counter = 0; 47 | 48 | int length = blurRadius*2+1; 49 | double[][] arr = new double[length][length]; 50 | 51 | for (int i=startX ; i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /BlurEffect/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 79 | 80 | 81 | 84 | 85 | 88 | 89 | 90 | 99 | 100 | 101 | 102 | 103 | true 104 | 105 | 106 | 107 | 108 | 109 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 146 | 147 | 148 | 149 | 152 | 153 | 156 | 157 | 158 | 159 | 162 | 163 | 166 | 167 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 203 | 204 | 205 | 218 | 219 | 220 | 233 | 234 | 235 | 253 | 254 | 255 | 274 | 275 | 276 | 289 | 290 | 291 | 308 | 309 | 330 | 343 | 344 | 353 | 357 | 358 | 359 | 366 | 369 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 439 | 446 | 447 | 448 | 449 | 450 | 451 | true 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 1459083700348 482 | 493 | 494 | 1459178156442 495 | 499 | 500 | 1459255117252 501 | 505 | 508 | 509 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 545 | 548 | 549 | 550 | 552 | 553 | 554 | 556 | 557 | 558 | 560 | 561 | 562 | 563 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | --------------------------------------------------------------------------------