# How to get Pixels intensities on a circles with radii R for an image with selective angles?

28 views (last 30 days)
Rashmi.D Jeya kumar on 12 Jan 2018
Edited: Rashmi.D Jeya kumar on 30 Jan 2018
How to get Pixels intensities on a circles with radii R for an image with selective angles?
Rashmi.D Jeya kumar on 12 Jan 2018

Image Analyst on 12 Jan 2018
Try this:
for k = 1 : length(x)
row = round(y(k)); % Round to nearest integer.
col = round(x(k)); % Round to nearest integer.
pixelValues(k) = grayImage(row, col);
end
Rashmi.D Jeya kumar on 30 Jan 2018
clc;
clear all;
close all;
M= imread('alu foil.jpg') ;
I=rgb2gray(M);
%I=mat2gray(N);
I1=imgaussfilt(I,2);
I2=imgaussfilt(I1,2);
I3=imgaussfilt(I2,2);
subplot(2,2,1);imshow(I);title('orginal image', 'FontSize', 10);
subplot(2,2,2);
imshow(I1);
title('1st Blur', 'FontSize', 10);
subplot(2,2,3);
imshow(I2);
title('2nd Blur', 'FontSize', 10);
subplot(2,2,4);
imshow(I3);
title('3rd Blur', 'FontSize', 10);
[ro co]=size(I);
for r = 2 : ro - 1
for c = 2 : co - 1
centerPixel = I(ro, co);
end
end
meanval = mean2(I);
ELBP_CI = double((centerPixel-meanval) >= 0);
P neighbors of a central pixel are evenly distributed on a circle with radius R and have intensities denoted as gp;By comparing neighboring pixels with their average value denoted as uR
spatial relationships of pixels on two circles with radius R,R'
R= 40;
xc=size(I)/2+.5;
yc=size(I)/2+.5;
Angles = [0, 45, 90, 135, 180, 225, 270, 315, 360] ;
x = xc(1)+R*cos(Angles*pi/180) ;
y = yc(1)+R*sin(Angles*pi/180) ;
for k = 1 : length(x)
row = round(y(k));
col = round(x(k));
pixelvalue(k) = I(row, col);
end
neighb_pixelsaverage=(pixelvalue(1)/9)+(pixelvalue(2)/9)+(pixelvalue(3)/9)+(pixelvalue(4)/9)+(pixelvalue(5)/9)+(pixelvalue(6)/9)+(pixelvalue(7)/9)+(pixelvalue(8)/9)+(pixelvalue(9)/9);
ELBPNI=0;
for i=1 : length(pixelvalue)
L=pixelvalue(i)-neighb_pixelsaverage;
if(L>=0)
M=1;
end
if (L<0)
M=0;
end
ELBPNI(i)=M*(2^i);
ELBPNI=ELBPNI+ELBPNI(i);
end
ELBP_NI=ELBPNI;
R=70;
x = xc(1)+R*cos(Angles*pi/180) ;
y = yc(1)+R*sin(Angles*pi/180) ;
for k = 1 : length(x)
row = round(y(k));
col = round(x(k));
pixelvalue1(k) = I(row, col);
end
neighb_pixelsaverage1=(pixelvalue1(1)/9)+(pixelvalue1(2)/9)+(pixelvalue1(3)/9)+(pixelvalue1(4)/9)+(pixelvalue1(5)/9)+(pixelvalue1(6)/9)+(pixelvalue1(7)/9)+(pixelvalue1(8)/9)+(pixelvalue1(9)/9);
ELBPNI=0;
for i=1 : length(pixelvalue)
L=pixelvalue1(i)-neighb_pixelsaverage1;
if(L>=0)
M=1;
if(L<0)
M=0;
end
ELBPNI1(i)=M*(2^i);
ELBPNI1=ELBPNI1+ELBPNI1(i);
end
end
ELBP_NI1=ELBPNI1;
for i=1 : length(pixelvalue)
L=pixelvalue(i)-pixelvalue1(i);
if(L>=0)
M=1;
if(L<0)
M=0;
end
ELBPRD(i)=M*(2^i);
ELBPRD=ELBPRD+ELBPRD(i);
end
end
ELBP_RD=ELBPRD;
I didnt complete entire code.up to this the code is right or any modifications?
clc;
clear all;
close all;
M= imread('alu foil.jpg') ;
I=rgb2gray(M);
%I=mat2gray(N);
I1=imgaussfilt(I,2);
I2=imgaussfilt(I1,2);
I3=imgaussfilt(I2,2);
subplot(2,2,1);imshow(I);title('orginal image', 'FontSize', 10);
subplot(2,2,2);
imshow(I1);
title('1st Blur', 'FontSize', 10);
subplot(2,2,3);
imshow(I2);
title('2nd Blur', 'FontSize', 10);
subplot(2,2,4);
imshow(I3);
title('3rd Blur', 'FontSize', 10);
[ro co]=size(I);
for r = 2 : ro - 1
for c = 2 : co - 1
centerPixel = I(ro, co);
end
end
meanval = mean2(I);
ELBP_CI = double((centerPixel-meanval) >= 0);
R= 40;
xc=size(I)/2+.5;
yc=size(I)/2+.5;
Angles = [0, 45, 90, 135, 180, 225, 270, 315, 360] ;
x = xc(1)+R*cos(Angles*pi/180) ;
y = yc(1)+R*sin(Angles*pi/180) ;
for k = 1 : length(x)
row = round(y(k));
col = round(x(k));
pixelvalue(k) = I(row, col);
end
neighb_pixelsaverage=(pixelvalue(1)/9)+(pixelvalue(2)/9)+(pixelvalue(3)/9)+(pixelvalue(4)/9)+(pixelvalue(5)/9)+(pixelvalue(6)/9)+(pixelvalue(7)/9)+(pixelvalue(8)/9)+(pixelvalue(9)/9);
ELBPNI=0;
for i=1 : length(pixelvalue)
L=pixelvalue(i)-neighb_pixelsaverage;
if(L>=0)
M=1;
end
if (L<0)
M=0;
end
ELBPNI(i)=M*(2^i);
ELBPNI=ELBPNI+ELBPNI(i);
end
ELBP_NI=ELBPNI;
R=70;
x = xc(1)+R*cos(Angles*pi/180) ;
y = yc(1)+R*sin(Angles*pi/180) ;
for k = 1 : length(x)
row = round(y(k));
col = round(x(k));
pixelvalue1(k) = I(row, col);
end
neighb_pixelsaverage1=(pixelvalue1(1)/9)+(pixelvalue1(2)/9)+(pixelvalue1(3)/9)+(pixelvalue1(4)/9)+(pixelvalue1(5)/9)+(pixelvalue1(6)/9)+(pixelvalue1(7)/9)+(pixelvalue1(8)/9)+(pixelvalue1(9)/9);
ELBPNI=0;
for i=1 : length(pixelvalue)
L=pixelvalue1(i)-neighb_pixelsaverage1;
if(L>=0)
M=1;
if(L<0)
M=0;
end
ELBPNI1(i)=M*(2^i);
ELBPNI1=ELBPNI1+ELBPNI1(i);
end
end
ELBP_NI1=ELBPNI1;
for i=1 : length(pixelvalue)
L=pixelvalue(i)-pixelvalue1(i);
if(L>=0)
M=1;
if(L<0)
M=0;
end
ELBPRD(i)=M*(2^i);
ELBPRD=ELBPRD+ELBPRD(i);
end
end
ELBP_RD=ELBPRD;

### More Answers (1)

KSSV on 12 Jan 2018
Edited: KSSV on 12 Jan 2018
I = imread('alu foil.jpg') ;
[nx,ny,d] = size(I) ;
R= 10 ;
figure
hold on
imshow(I) ;
[xc,yc] = getpts() ; % extract the center of circle
%
Angles = [0, 45, 90, 135, 180, 225, 270, 315, 360] ; % location in degrees
% In polar coordinates
iwant = [R*ones(1, length(Angles)); Angles*pi/180] ;
% In cartesian coordinates
x = xc(1)+R*cos(Angles*pi/180) ;
y = yc(1)+R*sin(Angles*pi/180) ;
%
hold on
plot(x,y,'*r') ;
%%Do interpolation to get pixels
R = uint8(interp2(1:ny,1:nx,double(I(:,:,1)),x,y)) ; % Red Channel
G = uint8(interp2(1:ny,1:nx,double(I(:,:,2)),x,y)) ; % Green Channel
B = uint8(interp2(1:ny,1:nx,double(I(:,:,3)),x,y)) ; % Blue Channel
When prompted...click at a point, where you want the circle to be. This point will be the center of circle.
##### 1 CommentShowHide None
Rashmi.D Jeya kumar on 12 Jan 2018
Thank you sir!! I am not geting the pixel value if R,G,B in comnd windw R=G=B (ie) same value.