2013-01-20 7 views
1

나는 2 개의 사진을 비교할 수있는 프로그램을 작성 중이다. 1은 샘플 색상이고 다른 하나는 편집 할 수있다. 먼저 픽셀 정보를 수집 한 후 다음과 같은 방법으로 후자를 편집합니다.안드로이드 자바의 이미지 색상 보정

결과 사진 : http://www.flickr.com/photos/[email protected]/8392038944/in/photostream

내 사진을 업데이트하고 품질/소음/색상에도 불구하고 있지만, 이상한 색상이 여기 저기가되고있다. 아무도 내가 그것을 제거하기 위해 무엇을해야하는지 모른다. 아니면 내가 사용하는 방법에 더 나은 개선? Heres the code :

입력은 편집 할 비트 맵, inColor는 편집 할 사진의 코 색상, reqcolor는 샘플/최적 사진의 코의 색상입니다.

public Bitmap shiftRGB(Bitmap input, int inColor, int reqColor){ 

    int deltaR = Color.red(reqColor) - Color.red(inColor); 
    int deltaG = Color.green(reqColor) - Color.green(inColor); 
    int deltaB = Color.blue(reqColor) - Color.blue(inColor); 

    //--how many pixels ? -- 
    int w = input.getWidth(); 
    int h = input.getHeight(); 


    //-- change em all! -- 
    for (int i = 0 ; i < w; i++){ 
     for (int j = 0 ; j < h ; j++){ 
      int pixColor = input.getPixel(i,j); 

      //-- colors now ? -- 
      int inR = Color.red(pixColor); 
      int inG = Color.green(pixColor); 
      int inB = Color.blue(pixColor); 

      if(inR > 255){ inR = 255;} 
      if(inG > 255){ inG = 255;} 
      if(inB > 255){ inB = 255;} 
      if(inR < 0){ inR = 0;} 
      if(inG < 0){ inG = 0;} 
      if(inB < 0){ inB = 0;} 

      //-- colors then -- 
      input.setPixel(i,j,Color.argb(255,inR + deltaR,inG + deltaG,inB   + deltaB)); 
     } 
    } 

    return input; 

} 도와 주셔서 감사합니다. 다른 감사를 전하는 것보다 더 감사드립니다!

답변

0

기능이 예상대로 작동하는 것 같습니다.

그러나 주목할 점은 실제로 새 픽셀의 최종 출력을 설정하기 전에 경계를 확인하기 위해 "if"사례를 사용하고 있다는 것입니다.

 if(inR > 255){ inR = 255;} 
     if(inG > 255){ inG = 255;} 
     if(inB > 255){ inB = 255;} 
     if(inR < 0){ inR = 0;} 
     if(inG < 0){ inG = 0;} 
     if(inB < 0){ inB = 0;} 
     input.setPixel(i,j,Color.argb(255,inR + deltaR,inG + deltaG,inB + deltaB)); 

나는 이것이 실제로하려는 것을 믿습니다.

 inR += deltaR 
     inG += deltaG 
     inB += deltaB 
     if(inR > 255){ inR = 255;} 
     if(inG > 255){ inG = 255;} 
     if(inB > 255){ inB = 255;} 
     if(inR < 0){ inR = 0;} 
     if(inG < 0){ inG = 0;} 
     if(inB < 0){ inB = 0;} 
     input.setPixel(i,j,Color.argb(255,inR,inG,inB)); 
+0

OMG! 나는 완전히 그것을 알아 차리지 못했다. 감사합니다 WLin! 문제가 해결되었습니다 :) – user1950532

관련 문제