楼主: 我是小趴菜
400 0

[数据挖掘新闻] 计算每个像素的灰度图像标准偏差 [推广有奖]

  • 0关注
  • 4粉丝

教授

35%

还不是VIP/贵宾

-

威望
0
论坛币
29650 个
通用积分
380.5350
学术水平
1 点
热心指数
1 点
信用等级
0 点
经验
7150 点
帖子
670
精华
0
在线时间
37 小时
注册时间
2022-8-30
最后登录
2023-4-4

楼主
我是小趴菜 发表于 2022-10-31 16:08:39 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

计算在每个像素处保持灰度图像的标准偏差的矩阵(即,X(i,j)保持在行i,列j处的所有图像的灰色像素强度的标准偏差。


我有(或相信我有)灰度的平均图像。我也有颜色的平均图像,但不认为这与此问题相关。我知道标准差需要我通过并总结每个值和平均值之间的差异,但不知道如何到达那里。


% Matrix initialization

setsum1 = zeros(215, 300, 3, 'double');

% Loop through all the image files in one directory and store in the matrix

filelist = dir('set1\*.jpg');

for i=1:length(filelist)

imname = ['\set1\' filelist(i).name];

nextim = imread(imname);

setsum1 = setsum1 + im2double(nextim);

end

% Compute the average image in color

setsum1_rgb = setsum1./length(filelist);

% Compute the average image in grayscale

setsum1_gray = rgb2gray(setsum1_rgb);

% grayscale images’ standard deviation at each pixel

deviation_setsum1_gray = sqrt(sum(power(??? - setsum1_gray, 2)));

解决办法:

您已经计算了平均图像。但是,如果要计算标准偏差,则必须记住所有图像上的所有图像强度。请记住,标准偏差定义为每行和列位置的图像强度之间的平方差之和的平方根,该位置的平均强度除以减去1的图像数量。因此我建议您存储图像为4D矩阵,其中第四维表示每个图像的颜色版本。我们还需要另一个类似的变量,但它将是一个3D矩阵,它将在第三维上存储每个图像的灰度版本。之后,我们可以最终计算每个空间位置的标准偏差。你甚至可以使用std 功能在第三维,所以你甚至不需要使用平均图像,但我假设你必须自己做。


假设你不能使用std,这样的东西会起作用:


% Loop through all the image files in one directory and store in the matrix

filelist = dir('set1\*.jpg');


% Matrix initialization

% New - Make the fourth channel as long as the total number of images

setsum1 = zeros(215, 300, 3, numel(filelist), 'double');


% New - Store the grayscale images too

% Make the third channel as long as the total number of images

setsum1_gray = zeros(215, 300, numel(filelist), 'double');


for i=1:length(filelist)

imname = ['\set1\' filelist(i).name];

nextim = imread(imname);

setsum1(:,:,:,i) = im2double(nextim); % New - Store the image per channel

setsum1_gray(:,:,i) = rgb2gray(setsum1(:,:,:,i)); % New - Grayscale convert the colour image and save it

end


% Compute the average image in grayscale and colour

% Note - I would just use mean if possible

% setsum1_gray_avg = mean(setsum1_gray, 3);

% setsum1_rgb = mean(setsum1, 4);

% ... or

% setsum1_gray_avg = sum(setsum1_gray, 3) / numel(filelist);

% setsum1_rgb = sum(setsum1, 4) / numel(filelist);

setsum1_rgb = zeros(215, 300, 3);

setsum1_gray_avg = zeros(215, 300);

for i = 1 : numel(filelist)

setsum1_rgb = setsum1_rgb + setsum1(:,:,:,i);

setsum1_gray_avg = setsum1_gray_avg + setsum1_gray(:,:,i);

end

setsum1_rgb = setsum1_rgb / numel(filelist);

setsum1_gray_avg = setsum1_gray_avg / numel(filelist);


% Now compute standard deviation for each pixel




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:标准偏差 Deviation directory Standard Director

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-22 15:20