フィルターのクリア

How to take pixels from an input image by using Gaussian sub-sampling (shotgun pattern like)?

2 ビュー (過去 30 日間)
Sara Salimi
Sara Salimi 2016 年 10 月 30 日
コメント済み: Image Analyst 2016 年 10 月 31 日
I want to take the locations of pixels that are to be taken like in a shotgun pattern concentrated in the middle of the image. Because I do not want to extract features of all pixels in an image. The output should be the coordinates of sampled pixels.
Is there any function or code that I can get help from that.
Your help is appreciated.

回答 (1 件)

Image Analyst
Image Analyst 2016 年 10 月 30 日
編集済み: Image Analyst 2016 年 10 月 30 日
Try this:
% Initialization / clean-up code.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 20;
numPoints = 5000;
xCenter = 1000;
yCenter = 1000;
sigmax = 300;
sigmay = 600;
x = xCenter + sigmax * randn(numPoints, 1);
y = yCenter + sigmay * randn(numPoints, 1);
% Make sure that we get rid of points that would not be in the image.
outSideImage = x < 1 | y < 1
x(outSideImage) = [];
y(outSideImage) = [];
% Plot the points.
plot(x, y, 'b.', 'MarkerSize', 8);
grid on;
axis square
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
  2 件のコメント
Sara Salimi
Sara Salimi 2016 年 10 月 31 日
Dear Image Analyst,
Thank you very much for your response and your help.
Image Analyst
Image Analyst 2016 年 10 月 31 日
If I've answered the question, then can you "Accept this answer", otherwise, ask your followup question.
One thing to note is that if you're using the code to get row and column indexes, you'll need to round x and y to the nearest integer, and you'll also have to make sure x and y don't get bigger than the number of rows and columns in the image. Also be aware of that (x,y) is not (row, column). x is column, not row, so if you put this into a loop where you're extracting image values you'll need to do something like
for k = 1 : length(x)
row = y(k);
col = x(k);
pixelValue = grayImage(row, column);
end
DO NOT do
pixelValue = grayImage(x(k), y(k));
because the first index is not x. It's y. You could do
pixelValue = grayImage(y(k), x(k));
if you'd rather do that than use row and column.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by