PHP grayscale to heatmap convert function mahler83, 2013-04-092013-11-07 PHP에서 0부터 255까지의 수치를 heatmap RGB 값으로 전환하는 함수입니다. (0-255 범위는 조정 가능합니다) Grayscale로 된 이미지 연산 결과를 heatmap으로 전환하기 위해 만들어봤습니다. The following PHP function converts a value between 0 to 255 into a heatmap RGB value. (The range 0 to 255 can be adjusted) I wrote this function to visualize a calcuation result as a heatmap. The brief concept is like this. The heatmap starts with a full (=255) blue color, and the green channel steeply increases. Then blue starts to steeply decrease to 0, while the green channel gets saturated. After the middle point, green minimally decreases while red quickly increases. In the end part, red gets saturated while green fades away swiftly. Ratio1 designates the value for Cyan, ratio2 for pure green, ratio3 for yellow. Here is the function with an example usage. <?php function heatmap($val, $min=0, $max=255) { // heatmap function by mahler83 2013.Apr.9 $ratio = ($val – $min) / ($max – $min); $ratio1 = 0.3; $ratio2 = 0.5; $ratio3 = 0.7; $cut = 200; if($ratio < $ratio1) { $ratioSpan = $ratio1; $r = 0; $g = $cut * $ratio / $ratioSpan; $b = (1 – $ratio / $ratioSpan) * (255-$cut) + $cut; } elseif($ratio < $ratio2) { $ratioSpan = $ratio2 – $ratio1; $r = 0; $g = ($ratio – $ratio1) / $ratioSpan * (255-$cut) + $cut; $b = (1 – ($ratio – $ratio1) / $ratioSpan) * $cut; } elseif($ratio < $ratio3) { $ratioSpan = $ratio3 – $ratio2; $r = ($ratio – $ratio2) / $ratioSpan * $cut; $g = (1 – ($ratio – $ratio2) / $ratioSpan) * (255-$cut) + $cut; $b = 0; } else { $ratioSpan = 1 – $ratio3; $r = ($ratio – $ratio3) / $ratioSpan * (255-$cut) + $cut; $g = (1 – ($ratio – $ratio3) / $ratioSpan) * $cut; $b = 0; } if($r < 0) $r = 0; if($g < 0) $g = 0; if($b < 0) $b = 0; if($r > 255) $r = 255; if($g > 255) $g = 255; if($b > 255) $b = 255; return array(round($r), round($g), round($b)); } $img = imagecreatetruecolor(2 * 256, 100); for($x = 1; $x <= 256 * 2; $x++) { $a = intval($x / 2); for($y = 1; $y <= 100; $y++) { $heat = heatmap($a); $color = imagecolorallocate($img, $heat[0], $heat[1], $heat[2]); imagesetpixel($img, $x, $y, $color); } } header(‘Content-type: image/jpeg’); imagejpeg($img); imagedestroy($img); ?> The code above will output something like the following. Share this:FacebookX PHP
키워드에서 태그를 뽑아내 태그 클라우드 만들기 2008-12-232013-11-08 write_update.tail.skin.php// 콤마로 explode해서 차례로 돌리기// 글 수정시 기존에 입력된 같은 wr_id, bo_table, gr_id 일단 다 지우고 새로 저장하자// 키워드, gr_id, bo_table, wr_id를 한 row로 저장// 키워드 테이블에 없으면 추가, 있으면 개수 새로 산정텍스트로만 된 내용물이라면 본문 내용에서 태그에 사용된 단어들은 자동으로 링크를 만들어주는 것이 가능할 것 같다.빠종이 만드는 only sentence를 기대해야지 ㅎ Share this:FacebookX Read More
PHP 최근 방문자수 그래프 – m3counter ver 1.10 2008-12-212013-11-08 방문자 수를 그래프로 표시해주는 플러그인입니다. 기존 버전에 대한 피드백을 받아 약간 개선시켰습니다. 의견 주신 분들 감사합니다.^^ ver 1.00과 달라진 점 : 1. 글씨 크기도 변수로 지정하도록. 수정 2. 그래프 하단에 날짜를 2자리 수로 표기 3. 그래프에 마우스를 대면 title로 요일이 한글로 뜨도록 – – – – – – – –… Share this:FacebookX Read More
Ubuntu에 APM 및 bind9 설치 & 세팅 practical manual 2012-09-222013-11-07 매번 찾아보기 귀찮아서 봇트윗 서버를 세팅하면서 단계별로 기록해봤다. 도메인 및 가상서버 결제 일단 업데이트부터 하고 # apt-get update # apt-get upgarde APM 설치 (phpmyadmin도 설치) # apt-get install apache2 # apt-get install libapache2-mod-auth-mysql # apt-get install mysql-server mysql-client # apt-get install php5-common php5 libapache2-mod-php5 # apt-get install php5-mysql # apt-get… Share this:FacebookX Read More