2011-02-11 5 views
1

나는 이미지 크기 조정 및 매트릭스를 사용하여 회전하고 있습니다 :비트 맵 : 선형 소음

촬영 bmp_orig
Matrix mtx = new Matrix(); 
if(orientation>0) { 
    mtx.postRotate(orientation); 
    Log.d(TAG,"image rotated: "+orientation); 
} 
if(scale<1) { 
    mtx.postScale(scale,scale); 
    Log.d(TAG,"image scaled: "+scale); 
} 
bmp = Bitmap.createBitmap(bm_orig, 0, 0, width, height, mtx, true); 
bm_orig.recycle(); 
bmp.compress(Bitmap.CompressFormat.JPEG,95,output); 
bmp.recycle(); 

3.2 Mpx 무료 카메라, 크기를 조정할 이미지를 사용하고 일반 보이는 회전.

하지만 소스가 4 Mpx 무료 또는 더 큰 경우, 크기 조정 후 결과 것은 내가 그나마

알고 거의-눈에 띄는 선형 소음을 가지고, 왜 노이즈가 나타나고, 그것을 어떻게 제거한다.

아무 아이디어 나? 크기를 조정하고 회전하는 또 다른 방법이 있습니까?

답변

0

이 문제는 원본 및 결과 이미지 크기와 관련이 있음을 발견했습니다.

원본 이미지 크기가 결과 크기보다 2 배 이상 큰 경우 이미지를로드하기 전에 이미지 크기를 확인한 다음 절반 크기 이미지를로드 할 때 해결되었습니다.

BitmapFactory.Options options_to_get_size = new BitmapFactory.Options(); 
options_to_get_size.inJustDecodeBounds = true; 
BitmapFactory.decodeStream(input, null, options_to_get_size); 
int load_scale = 1; // load 100% sized image 
int width_tmp=options_to_get_size.outWidth 
int height_tmp=options_to_get_size.outHeight; 

while(width_tmp/2>maxW && height_tmp/2>maxH){ 
width_tmp/=2;//load half sized image 
height_tmp/=2; 
load_scale*=2; 
} 
Log.d(TAG,"load inSampleSize: "+ load_scale); 

//Now load image with precalculated scale. scale must be power of 2 (1,2,4,8,16...) 
BitmapFactory.Options option_to_load = new BitmapFactory.Options(); 
option_to_load.inSampleSize = load_scale; 
((FileInputStream)input).getChannel().position(0); # reset input stream to read again 
Bitmap bm_orig = BitmapFactory.decodeStream(input,null,option_to_load); 

input.close(); 
//now you can resize and rotate image using matrix as stated in question