You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to get Pixels intensities on a circles with radii R for an image with selective angles?
3 views (last 30 days)
Show older comments
How to get Pixels intensities on a circles with radii R for an image with selective angles?
4 Comments
Rashmi.D Jeya kumar
on 12 Jan 2018
Edited: Walter Roberson
on 12 Jan 2018
Angles = [0, 45, 90, 135, 180, 225, 270, 315, 360] ; % location in degrees
% In polar coordinates
R=3;
iwant = [repmat(R,1, length(Angles)); Angles*pi/180]
% In cartesian coordinates
x = R*cos(Angles*pi/180) ;
y = R*cos(Angles*pi/180) ;
sir here where I insert my input image?
KSSV
on 12 Jan 2018
You have these location on circle...do you have any other image, for which you want to extract the pixel values?
Accepted Answer
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
8 Comments
Image Analyst
on 12 Jan 2018
You assigned it. You said R was = 3. Remember your code that you posted:
Angles = [0, 45, 90, 135, 180, 225, 270, 315, 360] ; % location in degrees
% In polar coordinates
R=3;
iwant = [repmat(R,1, length(Angles)); Angles*pi/180]
% In cartesian coordinates
x = R*cos(Angles*pi/180) ;
y = R*cos(Angles*pi/180) ;
See where it assigns the radius to 3? You did that. By the way, you can use cosd instead of cos, and sind instead of cos (which you wrongly used):
x = R * cosd(Angles); % The "d" versions take angles in degrees, not radians.
y = R * sind(Angles);
Image Analyst
on 12 Jan 2018
Well of course you were supposed to realize that you need to replace the image variable, grayImage, with the actual name of the variable in your program.
Maybe you didn't call it something useful and descriptive like grayImage. Maybe you called it I or X or something. Tell me exactly what you called your image variable when you called imread() (or somehow otherwise created it).
Image Analyst
on 19 Jan 2018
There is no zeroth row or zeroth column. You need to have rows and columns start at 1.
Rashmi.D Jeya kumar
on 30 Jan 2018
Edited: 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) ;
%%define your circle
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 Comment
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.
See Also
Categories
Find more on Deep Learning for Image Processing in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)