SlideShare une entreprise Scribd logo
1  sur  13
자바 기반 이미지 프로세싱

  1. 개요

  2. 구성도

  3. 목표

  4. 흑백

  5. 선명도

  6. 회전

  7. 데모
개요
 컴퓨터를 이용하여 생성된 영상자료 (이미지 또는 동영상 등)를 목적에 맞게
 처리하는 일련의 과정

 영상의 화질을 개선 하거나, 영상을 기하학적으로 변환하거나 영상의 특징
 을 두드러지게 변화 시키거나, 압축하는 작업을 포함

 방송, 영화, 의료, 산업현장, 사진편집, 출판 등 광범위한 분야에서 활용
구성도

PC (Swing/AWT)             Mobile (Android)        WEB (JSP/Servlet)




                          서버 (APM)

                          JSON   POST




                 camera
                                                 Image Processing
                           Android      bitmap         API
목표
 1. 자바언어에 대한 이해

 2. 모바일 플랫폼(Android)에 대한 이해

 3. 이미지 프로세싱에 대한 이해
흑백 이미지 (Grayscale)

  L = 0.2126 R + 0.7152 G + 0.0722 B

 Convert(“L”) 함수는 R,G,B 세개의 성분을 한 개의 광도(Luma) 성분으로 합성한다.
 이 계수들은 우리 눈이 느끼는 빨강, 파랑, 초록 삼원색의 밝기를 상대적 차이를 바탕으로 채택한 값




        RGB의 3원색을 흑백으로 변환한 결과
//그레이스케일
public static Bitmap doGreyscale(Bitmap src) {
        // constant factors
        final double GS_RED = 0.299;
        final double GS_GREEN = 0.587;
        final double GS_BLUE = 0.114;

       // create output bitmap
       Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
       // pixel information
       int A, R, G, B;
       int pixel;

       // get image size
       int width = src.getWidth();
       int height = src.getHeight();

       // scan through every single pixel
       for(int x = 0; x < width; ++x) {
                for(int y = 0; y < height; ++y) {
                         // get one pixel color
                         pixel = src.getPixel(x, y);
                         // retrieve color of all channels
                         A = Color.alpha(pixel);
                         R = Color.red(pixel);
                         G = Color.green(pixel);
                         B = Color.blue(pixel);
                         // take conversion up to one single value
                         R = G = B = (int)(GS_RED * R + GS_GREEN * G + GS_BLUE * B);
                         // set new pixel color to output bitmap
                         bmOut.setPixel(x, y, Color.argb(A, R, G, B));
                }
       }

       // return final image
       return bmOut;
}
선명도 (Sharpening)


    0     -1    0           -1     -1   -1
    -1     5    -1          -1     9    -1

    0     -1    0           -1     -1   -1


         마스크1                    마스크2



   영상을 선명하게 하는 마스크는 -1과 5, 9와 같은 0~1을 벗어난 값을
   사용한다는 것에 주목하자. 이렇게 되면 주변 픽셀보다 밝은 픽셀은
   더 밝아지게 되고, 주변 픽셀보다 어두운 픽셀은 더 어두워지게 되어
   서 픽셀들 사이의 명암도 차이가 두드러지고, 결과적으로 선명한 이미
   지가 얻어진다.
선명도 (Sharpening)




      마스크1         마스크2
final static int KERNAL_WIDTH = 3;
final static int KERNAL_HEIGHT = 3;

/* knl 값
int[][] kernalBlur = {
   {0, -1, 0},
   {-1, 5, -1},
   {0, -1, 0}
 };
*/
    public static Bitmap doSharpening(Bitmap src, int[][] knl) {
       Bitmap dest = Bitmap.createBitmap(
         src.getWidth(), src.getHeight(), src.getConfig());

    int bmWidth = src.getWidth();
    int bmHeight = src.getHeight();
    int bmWidth_MINUS_2 = bmWidth - 2;
    int bmHeight_MINUS_2 = bmHeight - 2;

    for(int i = 1; i <= bmWidth_MINUS_2; i++){
     for(int j = 1; j <= bmHeight_MINUS_2; j++){

      //get the surround 3*3 pixel of current src[i][j] into a matrix subSrc[][]
      int[][] subSrc = new int[KERNAL_WIDTH][KERNAL_HEIGHT];
      for(int k = 0; k < KERNAL_WIDTH; k++){
       for(int l = 0; l < KERNAL_HEIGHT; l++){
        subSrc[k][l] = src.getPixel(i-1+k, j-1+l);
       }
      }

      //subSum = subSrc[][] * knl[][]
      int subSumA = 0;
      int subSumR = 0;
      int subSumG = 0;
      int subSumB = 0;
회전(Convolution) – 기하학적 처리




              회전 좌표변환


  평면좌표를 점 (x,y)를 반시계 방향으로 각도 θ만큼 회전한 좌표
  는 (x cos θ – y sin θ, x sin θ + y cos θ) 이다
/* 회전 */
   public static Bitmap doRotate(Bitmap bmp, int nRotate, int viewW, int viewH){

        Matrix matrix = new Matrix();

        // 이미지의 해상도를 줄인다.

        /*float scaleWidth = ((float) newWidth) / width;

        float scaleHeight = ((float) newHeight) / height;

        matrix.postScale(scaleWidth, scaleHeight);*/


        matrix.postRotate(nRotate); // 회전

        // 이미지를 회전시킨다
        Bitmap rotateBitmap = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);


        // View 사이즈에 맞게 이미지를 조절한다.
        Bitmap resize = Bitmap.createScaledBitmap(rotateBitmap, viewW, viewH, true);

        return resize;

 }
참고자료

http://yagi815.tistory.com/242

http://mainia.tistory.com/602

http://xjaphx.wordpress.com/learning/tutorials/

http://kylog.tistory.com/19

http://www.lac.inpe.br/JIPCookbook/index.jsp
DEMO

Contenu connexe

Tendances

[역해석 방법] 주성분 분석을 이용한 이미지 복원 및 압축 그리고 주성분 회귀모형을 이용한 광대역 알베도 산출
[역해석 방법] 주성분 분석을 이용한 이미지 복원 및 압축 그리고 주성분 회귀모형을 이용한 광대역 알베도 산출[역해석 방법] 주성분 분석을 이용한 이미지 복원 및 압축 그리고 주성분 회귀모형을 이용한 광대역 알베도 산출
[역해석 방법] 주성분 분석을 이용한 이미지 복원 및 압축 그리고 주성분 회귀모형을 이용한 광대역 알베도 산출Lee Sang-Ho
 
투명화 처리로 살펴 본 한층 고급화된 모바일 UX
투명화 처리로 살펴 본 한층 고급화된 모바일 UX투명화 처리로 살펴 본 한층 고급화된 모바일 UX
투명화 처리로 살펴 본 한층 고급화된 모바일 UXDae Yeon Jin
 
아일렛 온라인에서 사용한 블럭 렌더링 소개
아일렛 온라인에서 사용한 블럭 렌더링 소개아일렛 온라인에서 사용한 블럭 렌더링 소개
아일렛 온라인에서 사용한 블럭 렌더링 소개정만 김
 
PiCANet, Pytorch Implementation (Korean)
PiCANet, Pytorch Implementation (Korean)PiCANet, Pytorch Implementation (Korean)
PiCANet, Pytorch Implementation (Korean)JaehoonYoo5
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해SangYun Yi
 
선호 언어 셋팅 방법 (How to set language preference)
선호 언어 셋팅 방법 (How to set language preference)선호 언어 셋팅 방법 (How to set language preference)
선호 언어 셋팅 방법 (How to set language preference)Sun Mi Seo
 
리얼타임 렌더링 - 조명 입문편 -
리얼타임 렌더링 - 조명  입문편 -리얼타임 렌더링 - 조명  입문편 -
리얼타임 렌더링 - 조명 입문편 -Sukwoo Lee
 

Tendances (7)

[역해석 방법] 주성분 분석을 이용한 이미지 복원 및 압축 그리고 주성분 회귀모형을 이용한 광대역 알베도 산출
[역해석 방법] 주성분 분석을 이용한 이미지 복원 및 압축 그리고 주성분 회귀모형을 이용한 광대역 알베도 산출[역해석 방법] 주성분 분석을 이용한 이미지 복원 및 압축 그리고 주성분 회귀모형을 이용한 광대역 알베도 산출
[역해석 방법] 주성분 분석을 이용한 이미지 복원 및 압축 그리고 주성분 회귀모형을 이용한 광대역 알베도 산출
 
투명화 처리로 살펴 본 한층 고급화된 모바일 UX
투명화 처리로 살펴 본 한층 고급화된 모바일 UX투명화 처리로 살펴 본 한층 고급화된 모바일 UX
투명화 처리로 살펴 본 한층 고급화된 모바일 UX
 
아일렛 온라인에서 사용한 블럭 렌더링 소개
아일렛 온라인에서 사용한 블럭 렌더링 소개아일렛 온라인에서 사용한 블럭 렌더링 소개
아일렛 온라인에서 사용한 블럭 렌더링 소개
 
PiCANet, Pytorch Implementation (Korean)
PiCANet, Pytorch Implementation (Korean)PiCANet, Pytorch Implementation (Korean)
PiCANet, Pytorch Implementation (Korean)
 
Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해Display color와 Digital texture format의 이해
Display color와 Digital texture format의 이해
 
선호 언어 셋팅 방법 (How to set language preference)
선호 언어 셋팅 방법 (How to set language preference)선호 언어 셋팅 방법 (How to set language preference)
선호 언어 셋팅 방법 (How to set language preference)
 
리얼타임 렌더링 - 조명 입문편 -
리얼타임 렌더링 - 조명  입문편 -리얼타임 렌더링 - 조명  입문편 -
리얼타임 렌더링 - 조명 입문편 -
 

En vedette

Processing 기초 이해하기_20160713
Processing 기초 이해하기_20160713Processing 기초 이해하기_20160713
Processing 기초 이해하기_20160713Yong Joon Moon
 
Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석용 최
 
Assignment sept 2011 aj
Assignment sept 2011 ajAssignment sept 2011 aj
Assignment sept 2011 ajNasir Noor
 
To rs for consultancy environment firm tourism projects new
To rs for consultancy environment firm tourism projects newTo rs for consultancy environment firm tourism projects new
To rs for consultancy environment firm tourism projects newhayat alishah
 
LeanLaunchpad_finaldemo_ContactTree
LeanLaunchpad_finaldemo_ContactTreeLeanLaunchpad_finaldemo_ContactTree
LeanLaunchpad_finaldemo_ContactTreeAna
 
Stc final presentation
Stc final presentationStc final presentation
Stc final presentationhayat alishah
 
Pc i festival traditional events 2014-15 50m
Pc i festival traditional events 2014-15 50mPc i festival traditional events 2014-15 50m
Pc i festival traditional events 2014-15 50mhayat alishah
 
Md if tourism ismdmspstc160108 (2013 03 16 21_37_30 utc)
Md if tourism ismdmspstc160108 (2013 03 16 21_37_30 utc)Md if tourism ismdmspstc160108 (2013 03 16 21_37_30 utc)
Md if tourism ismdmspstc160108 (2013 03 16 21_37_30 utc)hayat alishah
 
Informatoin 2 chapter 6 international tourism markets
Informatoin 2 chapter 6 international tourism marketsInformatoin 2 chapter 6 international tourism markets
Informatoin 2 chapter 6 international tourism marketshayat alishah
 

En vedette (18)

Processing 기초 이해하기_20160713
Processing 기초 이해하기_20160713Processing 기초 이해하기_20160713
Processing 기초 이해하기_20160713
 
Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석Python 활용: 이미지 처리와 데이터 분석
Python 활용: 이미지 처리와 데이터 분석
 
Seahenge
SeahengeSeahenge
Seahenge
 
Sustainable development
Sustainable developmentSustainable development
Sustainable development
 
Assignment sept 2011 aj
Assignment sept 2011 ajAssignment sept 2011 aj
Assignment sept 2011 aj
 
To rs for consultancy environment firm tourism projects new
To rs for consultancy environment firm tourism projects newTo rs for consultancy environment firm tourism projects new
To rs for consultancy environment firm tourism projects new
 
Discovery and investigation
Discovery and investigationDiscovery and investigation
Discovery and investigation
 
Early Neolithic 2013
Early Neolithic 2013Early Neolithic 2013
Early Neolithic 2013
 
LeanLaunchpad_finaldemo_ContactTree
LeanLaunchpad_finaldemo_ContactTreeLeanLaunchpad_finaldemo_ContactTree
LeanLaunchpad_finaldemo_ContactTree
 
Hochdorf
HochdorfHochdorf
Hochdorf
 
Stc final presentation
Stc final presentationStc final presentation
Stc final presentation
 
Service rule
Service ruleService rule
Service rule
 
Pc i festival traditional events 2014-15 50m
Pc i festival traditional events 2014-15 50mPc i festival traditional events 2014-15 50m
Pc i festival traditional events 2014-15 50m
 
Md if tourism ismdmspstc160108 (2013 03 16 21_37_30 utc)
Md if tourism ismdmspstc160108 (2013 03 16 21_37_30 utc)Md if tourism ismdmspstc160108 (2013 03 16 21_37_30 utc)
Md if tourism ismdmspstc160108 (2013 03 16 21_37_30 utc)
 
Irs 22.2.2015
Irs 22.2.2015Irs 22.2.2015
Irs 22.2.2015
 
Informatoin 2 chapter 6 international tourism markets
Informatoin 2 chapter 6 international tourism marketsInformatoin 2 chapter 6 international tourism markets
Informatoin 2 chapter 6 international tourism markets
 
Aj vm pdf
Aj vm pdfAj vm pdf
Aj vm pdf
 
Information
InformationInformation
Information
 

Similaire à 이미지프로세싱

이정근_project_로봇비전시스템.pdf
이정근_project_로봇비전시스템.pdf이정근_project_로봇비전시스템.pdf
이정근_project_로봇비전시스템.pdftangtang1026
 
이미지 프로세싱 in Python Open Source - PYCON KOREA 2020
이미지 프로세싱 in Python Open Source - PYCON KOREA 2020이미지 프로세싱 in Python Open Source - PYCON KOREA 2020
이미지 프로세싱 in Python Open Source - PYCON KOREA 2020Kenneth Ceyer
 
[0326 박민근] deferred shading
[0326 박민근] deferred shading[0326 박민근] deferred shading
[0326 박민근] deferred shadingMinGeun Park
 
Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objectsyong gyun im
 
Canvas_basic tutorial
Canvas_basic tutorialCanvas_basic tutorial
Canvas_basic tutorialfairesy
 
영상 데이터의 처리와 정보의 추출
영상 데이터의 처리와 정보의 추출영상 데이터의 처리와 정보의 추출
영상 데이터의 처리와 정보의 추출동윤 이
 
[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shadingMinGeun Park
 
공간데이터베이스(Spatial db)
공간데이터베이스(Spatial db)공간데이터베이스(Spatial db)
공간데이터베이스(Spatial db)H.J. SIM
 

Similaire à 이미지프로세싱 (11)

이정근_project_로봇비전시스템.pdf
이정근_project_로봇비전시스템.pdf이정근_project_로봇비전시스템.pdf
이정근_project_로봇비전시스템.pdf
 
Open gl
Open glOpen gl
Open gl
 
Color Control
Color ControlColor Control
Color Control
 
이미지 프로세싱 in Python Open Source - PYCON KOREA 2020
이미지 프로세싱 in Python Open Source - PYCON KOREA 2020이미지 프로세싱 in Python Open Source - PYCON KOREA 2020
이미지 프로세싱 in Python Open Source - PYCON KOREA 2020
 
[0326 박민근] deferred shading
[0326 박민근] deferred shading[0326 박민근] deferred shading
[0326 박민근] deferred shading
 
[Week4]canvas
[Week4]canvas[Week4]canvas
[Week4]canvas
 
Rendering realistic Ice objects
Rendering realistic Ice objectsRendering realistic Ice objects
Rendering realistic Ice objects
 
Canvas_basic tutorial
Canvas_basic tutorialCanvas_basic tutorial
Canvas_basic tutorial
 
영상 데이터의 처리와 정보의 추출
영상 데이터의 처리와 정보의 추출영상 데이터의 처리와 정보의 추출
영상 데이터의 처리와 정보의 추출
 
[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading
 
공간데이터베이스(Spatial db)
공간데이터베이스(Spatial db)공간데이터베이스(Spatial db)
공간데이터베이스(Spatial db)
 

이미지프로세싱

  • 1. 자바 기반 이미지 프로세싱 1. 개요 2. 구성도 3. 목표 4. 흑백 5. 선명도 6. 회전 7. 데모
  • 2. 개요 컴퓨터를 이용하여 생성된 영상자료 (이미지 또는 동영상 등)를 목적에 맞게 처리하는 일련의 과정 영상의 화질을 개선 하거나, 영상을 기하학적으로 변환하거나 영상의 특징 을 두드러지게 변화 시키거나, 압축하는 작업을 포함 방송, 영화, 의료, 산업현장, 사진편집, 출판 등 광범위한 분야에서 활용
  • 3. 구성도 PC (Swing/AWT) Mobile (Android) WEB (JSP/Servlet) 서버 (APM) JSON POST camera Image Processing Android bitmap API
  • 4. 목표 1. 자바언어에 대한 이해 2. 모바일 플랫폼(Android)에 대한 이해 3. 이미지 프로세싱에 대한 이해
  • 5. 흑백 이미지 (Grayscale) L = 0.2126 R + 0.7152 G + 0.0722 B Convert(“L”) 함수는 R,G,B 세개의 성분을 한 개의 광도(Luma) 성분으로 합성한다. 이 계수들은 우리 눈이 느끼는 빨강, 파랑, 초록 삼원색의 밝기를 상대적 차이를 바탕으로 채택한 값 RGB의 3원색을 흑백으로 변환한 결과
  • 6. //그레이스케일 public static Bitmap doGreyscale(Bitmap src) { // constant factors final double GS_RED = 0.299; final double GS_GREEN = 0.587; final double GS_BLUE = 0.114; // create output bitmap Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig()); // pixel information int A, R, G, B; int pixel; // get image size int width = src.getWidth(); int height = src.getHeight(); // scan through every single pixel for(int x = 0; x < width; ++x) { for(int y = 0; y < height; ++y) { // get one pixel color pixel = src.getPixel(x, y); // retrieve color of all channels A = Color.alpha(pixel); R = Color.red(pixel); G = Color.green(pixel); B = Color.blue(pixel); // take conversion up to one single value R = G = B = (int)(GS_RED * R + GS_GREEN * G + GS_BLUE * B); // set new pixel color to output bitmap bmOut.setPixel(x, y, Color.argb(A, R, G, B)); } } // return final image return bmOut; }
  • 7. 선명도 (Sharpening) 0 -1 0 -1 -1 -1 -1 5 -1 -1 9 -1 0 -1 0 -1 -1 -1 마스크1 마스크2 영상을 선명하게 하는 마스크는 -1과 5, 9와 같은 0~1을 벗어난 값을 사용한다는 것에 주목하자. 이렇게 되면 주변 픽셀보다 밝은 픽셀은 더 밝아지게 되고, 주변 픽셀보다 어두운 픽셀은 더 어두워지게 되어 서 픽셀들 사이의 명암도 차이가 두드러지고, 결과적으로 선명한 이미 지가 얻어진다.
  • 8. 선명도 (Sharpening) 마스크1 마스크2
  • 9. final static int KERNAL_WIDTH = 3; final static int KERNAL_HEIGHT = 3; /* knl 값 int[][] kernalBlur = { {0, -1, 0}, {-1, 5, -1}, {0, -1, 0} }; */ public static Bitmap doSharpening(Bitmap src, int[][] knl) { Bitmap dest = Bitmap.createBitmap( src.getWidth(), src.getHeight(), src.getConfig()); int bmWidth = src.getWidth(); int bmHeight = src.getHeight(); int bmWidth_MINUS_2 = bmWidth - 2; int bmHeight_MINUS_2 = bmHeight - 2; for(int i = 1; i <= bmWidth_MINUS_2; i++){ for(int j = 1; j <= bmHeight_MINUS_2; j++){ //get the surround 3*3 pixel of current src[i][j] into a matrix subSrc[][] int[][] subSrc = new int[KERNAL_WIDTH][KERNAL_HEIGHT]; for(int k = 0; k < KERNAL_WIDTH; k++){ for(int l = 0; l < KERNAL_HEIGHT; l++){ subSrc[k][l] = src.getPixel(i-1+k, j-1+l); } } //subSum = subSrc[][] * knl[][] int subSumA = 0; int subSumR = 0; int subSumG = 0; int subSumB = 0;
  • 10. 회전(Convolution) – 기하학적 처리 회전 좌표변환 평면좌표를 점 (x,y)를 반시계 방향으로 각도 θ만큼 회전한 좌표 는 (x cos θ – y sin θ, x sin θ + y cos θ) 이다
  • 11. /* 회전 */ public static Bitmap doRotate(Bitmap bmp, int nRotate, int viewW, int viewH){ Matrix matrix = new Matrix(); // 이미지의 해상도를 줄인다. /*float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; matrix.postScale(scaleWidth, scaleHeight);*/ matrix.postRotate(nRotate); // 회전 // 이미지를 회전시킨다 Bitmap rotateBitmap = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); // View 사이즈에 맞게 이미지를 조절한다. Bitmap resize = Bitmap.createScaledBitmap(rotateBitmap, viewW, viewH, true); return resize; }
  • 13. DEMO