How to get Pixels intensities on a circles with radii R for an image with selective angles?
7 次查看(过去 30 天)
显示 更早的评论
How to get Pixels intensities on a circles with radii R for an image with selective angles?
4 个评论
Rashmi.D Jeya kumar
2018-1-12
编辑:Walter Roberson
2018-1-12
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/187547/image.png)
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
2018-1-12
You have these location on circle...do you have any other image, for which you want to extract the pixel values?
采纳的回答
Image Analyst
2018-1-12
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 个评论
Image Analyst
2018-1-12
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
2018-1-12
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
2018-1-19
There is no zeroth row or zeroth column. You need to have rows and columns start at 1.
Rashmi.D Jeya kumar
2018-1-30
编辑:Rashmi.D Jeya kumar
2018-1-30
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/187678/image.png)
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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/187679/image.png)
[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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/187680/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/187681/image.png)
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;
更多回答(1 个)
KSSV
2018-1-12
编辑:KSSV
2018-1-12
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 个评论
Rashmi.D Jeya kumar
2018-1-12
Thank you sir!! I am not geting the pixel value if R,G,B in comnd windw R=G=B (ie) same value.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/187550/image.png)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)