2013-06-02 2 views
2

완전 백색 열의 모든 흰색 픽셀을 다른 색상으로 바꾸고 싶습니다. 열의 검정색 픽셀이 있으면 아무 것도 바뀌지 않지만 어디에서 문제가 있는지는 알 수 없습니다 ...흰색 픽셀 라인 찾기

function findLines() { 
    $blank = 1; 
    $im_1 = imageCreateFromPng('resize_1.png'); 
    for($i=0; $i<1090; $i++) { 
     if($blank == 1) { 
      for($j=0; $j<240; $j++) { 
       $rgb = imageColorAt($im_1, $i, $j); 
       $r = ($rgb >> 16) & 0xFF; 
       $g = ($rgb >> 8) & 0xFF; 
       $b = $rgb & 0xFF; 
       $c = $r.$g.$b; 
       if($c === "0 0 0") { 
        $blank = 0; 
       } 
       $color = imageColorAllocate($im_1, 0, 255, 255);  
       imageSetPixel($im_1, $i, $j, $color); 
      } 
     } 
     if ($blank == 0) { 
      for($j=0; $j<240; $j++) { 
       $rgb = imageColorAt($im_1, $i, $j); 
       $r = ($rgb >> 16) & 0xFF; 
       $g = ($rgb >> 8) & 0xFF; 
       $b = $rgb & 0xFF; 
       $c = $r . " " . $g . " " . $b; 
       if($c === "255 255 255") { 
        $blank = 1; 
       } 


      } 
     } else { 
      $blank = 0; 
     } 
    } 
    header("Content-Type: image/png"); 
    imagepng($im_1); 
} 

답변

0

이 오른쪽 하나입니다 : 여기

는 코드입니다. 어쨌든 고마워!

function findLines() { 
    $im_1 = imageCreateFromPng('resize_1.png'); 
    for($i=0; $i<1090; $i++) { 
     $blank = 1; 
     for($j=0; $j<240; $j++) { 
      $rgb = imageColorAt($im_1, $i, $j); 
      if($rgb == 0) { 
       $blank = 0; 
      } 
     } 
     if ($blank == 1) { 
      for($j=0; $j<240; $j++) { 
       $color = imageColorAllocate($im_1, 155, 155, 155); 
       imageSetPixel($im_1, $i, $j, $color); 
      } 
     } else { 
      $blank = 0; 
     } 
    } 
    header("Content-Type: image/png"); 
    imagepng($im_1); 
}