請幫我算一下圖像中的像素數量,或者放出RGB數組。如何計算圖像中的像素數量(php)
所以這是腳本泰德給我從陣列的一個元件:
<?php
$img = "1.png";
$imgHand = imagecreatefrompng("$img");
$imgSize = GetImageSize($img);
$imgWidth = $imgSize[0];
$imgHeight = $imgSize[1];
echo '<img src="'.$img.'"><br><br>';
for ($l = 0; $l < $imgHeight; $l++) {
for ($c = 0; $c < $imgWidth; $c++) {
$pxlCor = ImageColorAt($imgHand,$c,$l);
$pxlCorArr = ImageColorsForIndex($imgHand, $pxlCor);
}
}
print_r($pxlCorArr);
?>
抱歉,我的英語我從烏克蘭
'$ numOfPix = $ imgWidth * $ imgHeight;' – Petah
你究竟在做什麼?圖像中的像素總數,如imgwidth x imageheight或什麼? – Graviton
我相信他想要一個整個圖像的'$ pxlCorArr',其中索引是像素,顏色值..否則他的代碼沒有任何意義。 – dbf