<?php function mode($arr) { $count = array_count_values($arr); $best = max($count); return array_keys($count, $best); } print_r(mode(array(1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17))); print_r(mode(array(1, 1, 2, 4, 4)));
global $TEXT; global $_GET; switch ($_GET['mode']) { case 'settings': return $TEXT['Settings']; break; case 'home': return $TEXT['Homepage']; break; case 'staff': return $TEXT['Staff']; break; default: return $_GET['mode']; break; } } ?> <div class="titlebar"><br /> <div class="toptitle"><?php echo submode(); ?> </div> <div class="route"><?php echo mode(); ?> / <?php echo submode(); ?> </div> </div>
public function setMode($mode = "") { $this->getConnection()->mode = $mode; if (empty($mode)) { $this->getConnection() > mode(MSSQL_ASSOC); } }
public function colourCalibrate($colours, $expand = 25, $SD = 2) { // $colours lists x-coordinate, y-coordinate, and L, a* and b* values for each colour on the checker chart // $expand = number of pixels plus or minus the reference x and y-corrdinates // $SD = exclude pixels more than $sd standard deviations from the mean for that area if (!imageistruecolor($this->_image)) { return false; } $w = $this->getWidth(); $h = $this->getHeight(); $rgb255 = array(); foreach ($colours as $cname => $c) { // get color from x and y coordinates $imgcolor = array(); for ($x = $c[0] - $expand; $x <= $c[0] + $expand; $x++) { for ($y = $c[1] - $expand; $y <= $c[1] + $expand; $y++) { $rgb = imagecolorat($this->_image, $x, $y); $imgcolor['r'][] = $rgb >> 16 & 0xff; $imgcolor['g'][] = $rgb >> 8 & 0xff; $imgcolor['b'][] = $rgb & 0xff; } } foreach ($imgcolor as $rgb => $valuearray) { $mode = mode($valuearray, 0.25); $stdev = stdev($valuearray); foreach ($valuearray as $i => $v) { if ($v > $mode + $SD * $stdev || $v < $mode - $SD * $stdev) { // remove from list unset($valuearray[$i]); } } $averages[$rgb] = round(mean($valuearray), 12); $stdevs[$rgb] = round(stdev($valuearray), 4); $counts[$rgb] = count($valuearray); } $rgb255[] = $averages; $lab = rgb2lab($averages['r'], $averages['g'], $averages['b']); $deltaE = deltaE($lab, array($c[2], $c[3], $c[4])); $check[$cname] = sprintf("Lab(%.1f, %.1f, %.1f)\n", round($lab['L'], 1), round($lab['a'], 1), round($lab['b'], 1)); /* $check .= "--myLab: (" . implode(',', $lab['lab']) . ")\n"; $check .= "--chartLab: ($c[2], $c[3], $c[4])\n"; $check .= "--deltaE = $deltaE\n"; $check .= "--RGB: (" . implode(',', $averages) . ")\n"; $check .= "--SD: (" . implode(',', $stdevs) . ")\n"; $check .= "--N: (" . implode(',', $counts) . ")\n"; */ if (!is_nan($deltaE)) { $deltaEs[] = $deltaE; } } $meanDeltaE = round(mean($deltaEs), 4); $maxDeltaE = round(max($deltaEs), 4); $patch = $expand * 2 + 1; $this->setDescription(array("colour calibrate" => array("path dimension" => "{$patch} x {$patch}", "SD" => $SD, "deltaE" => array("M" => $meanDeltaE, "max" => $maxDelta), "check" => $check))); /* MATLAB code ************************************ % Calculate camera Characterisation - Least Squares fit of rgb to Lab patches: rgb = Rgb_vals/255; for i = 1:length(rgb) train(i,:) = rgb2rgbpoly(rgb(i,:),11); end R=train\spectrod65; % Calculate predicted lab values from characterisation lab_calc = train*R; squaredDifference = (lab_calc-spectrod65).^2; meanDeltaE = mean(sqrt(sum(squaredDifference'))) maxDeltaE = max(sqrt(sum(squaredDifference'))) **************************************************/ include_once "Math/Matrix.php"; foreach ($colours as $v) { $spectrod65[] = array($v[2], $v[3], $v[4]); } foreach ($rgb255 as $i => $v) { foreach ($v as $j => $c) { $rgb1[$i][] = $c / 255; } } foreach ($rgb1 as $v) { $train[] = rgb2rgbpoly($v, 11); } $rgbM = new Math_Matrix($rgb1); $trainM = new Math_matrix($train); return $this; }
<?php } ?> <?php } ?> </ul> </div> <div class="col-md-10"> <h2>글쓰기</h2> <form name="writeForm" method="post" enctype="multipart/form-data" action="<?php echo MAIN_URL; ?> /<?php echo $board_config['bc_code']; echo mode($type, isset($board['b_idx']) ? $board['b_idx'] : ''); ?> " onsubmit="return formChk();"> <input type="hidden" name="bc_code" value="<?php echo $board_config['bc_code']; ?> " /> <label for="b_title">글제목</label> <input type="text" id="b_title" name="b_title" value="<?php echo $type == 'm' && isset($board['b_title']) ? $board['b_title'] : ''; ?> " /> <label for="m_name">작성자</label> <input type="text" id="m_name" name="m_name" value="<?php echo $this->session->userdata('user_name') != '' ? $this->session->userdata('user_name') . '" readonly="readonly' : ''; ?>