gpt4 book ai didi

c - 如何从 PGM 图像创建直方图

转载 作者:行者123 更新时间:2023-11-30 18:58:12 25 4
gpt4 key购买 nike

我需要为类项目创建 PGM 图像的单个灰度直方图。我已经有了读取 PGM 图像的代码。但是我不完全理解如何计算唯一的像素值。我不需要输出图表或类似的东西。任何帮助将不胜感激!

读取PGM图像的代码 http://sun.iwu.edu/~shelley/sie/zoo/journal/pgm.c.html

最佳答案

伪代码,假设8位灰度图像:

int histogram[256] = { 0 };     ; init histogram of all possible grey values to all zero

for i = 0 to rows - 1 ; for each row
for j = 0 to cols - 1 ; for each col
p = image[i][j] ; get pixel value
histogram[p]++ ; increment histogram bin

关于c - 如何从 PGM 图像创建直方图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17765599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com