필터 지우기
필터 지우기

Index in position 2 exceeds array bounds. Error in (line 36) sum(i,j)= (local(i,j)-mean )/Variance_final;??? how can i solve it ?

조회 수: 2 (최근 30일)
clc; clear; close all;
%% Read Cover Image
cover_image=imread('lena_rgb.bmp');
% Grab the image information (metadata) of input image using the function imfinfo
inputImageInfo=imfinfo('lena_rgb.bmp');
figure;
h1=imshow(cover_image);
title('Original Cover Image')
% Convert cover image from rgb to YCbCr
cover_image_YCbCr=rgb2ycbr(cover_image);
figure;
h2=imshow(cover_image_YCbCr);
title('YCbCr Cover image')
% Convert the image from uint8 to double
cover_image_YCbCr=double(cover_image_YCbCr);
% Find the size (columns and rows) of the input image and assign the rows to
% variable nr, and columns to variable nc
[nr,nc] = size(cover_image_YCbCr);
%% Conmpute Cb component of YCbCr Cover Image
cb_component = cover_image_YCbCr(:, 1, :);
% Convert Y to double format
cb_component_d=double(cb_component);
%normalize cb channel
local=rangefilt(cb_component,true(3));%local range of pixel intensity
mean=mean2(double(local));%mean
sdImage = stdfilt(local, true(3));%standard devieation
Variance_final = mean2(var(double(local)));%varience
%sdImage = stdfilt(cb_component, true(3));% Now sdImage is the std dev within a 3-by-3 window around each pixel.
variace=var(double(local)) ;
[mr,mc]= size(local);
sum=zeros(mr,mc);%to compute color consistency of image
for i=1:1:mc
for j=1:1:mr
sum(i,j)= (local(i,j)-mean )/Variance_final;
end
end

답변 (1개)

Shubhankar Poundrik
Shubhankar Poundrik 2020년 6월 6일
Hi Bashar,
It appears that the number of rows and the number of columns are switched in the for loop. The variables 'mc' and 'mr' should be switched.
Try replacing the 'for loop' at the end with the following:
for i=1:1:mr
for j=1:1:mc
sum(i,j)= (local(i,j)-mean )/Variance_final;
end
end
Reagrds,
Shubhankar.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by