Picking every nth pixel on the x axis in images (matlab)

조회 수: 5 (최근 30일)
Elf
Elf 2017년 7월 18일
편집: Elf 2017년 7월 18일
I am trying to pick every nth pixel in 600x600 image. I am not sure how to do and search as while doing it. I wrote a code and I didn't understand why it selects every 20th pixel in y axis but it selects every pixels in x axis. I wanna choose every pixel in y axis and every 20th pixel in x axis. How can I fix this? I attached the image result too.Here is my code;
I = imread('2.jpg');
I = imresize(I,[600,600]);
a = rgb2gray(I);
imshow(a);
[hy,hx]=find(a);
% choose every nth pixel
n = 20;
hxr = hx(1:n:end);
hyr = hy(1:n:end);
% plot
figure(10); clf;
imshow(I);
hold on;
plot(hxr,hyr,'r+');
% extract features + visualization object
[features,validPoints,visualization] = extractHOGFeatures(I,[hxr,hyr],'CellSize',[4 4]);
% show image and features
figure(20); clf;
imshow(I);
hold on;
plot(visualization,'Color','b');
% plot valid points for horizon
plot(validPoints(:,1),validPoints(:,2),'go');
  댓글 수: 1
Adam
Adam 2017년 7월 18일
Just flip around your x and y if that is your only problem. It is easy to get this wrong because you have to remember that array access is of the form
(row,column)
but row is actually equivalent to y and column to x so you need to index as (y,x) in that case.
Is that the only problem or are you saying you expect every 20th pixel in both x and y?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by