필터 지우기
필터 지우기

Extracting information from a plot

조회 수: 3 (최근 30일)
jgillis16
jgillis16 2016년 1월 6일
댓글: jgillis16 2016년 1월 8일
I have a map of objects on a basic plot. there are areas on the plot that don’t have many objects at all. I want to identify and extract these ‘void’ areas on my plot. I was thinking of setting a threshold of less than 5 objects per ‘degree’ on the plot will count as a ‘void’ area. How would I go about doing this?
  댓글 수: 3
jgillis16
jgillis16 2016년 1월 7일
jgillis16
jgillis16 2016년 1월 7일
But, just focusing on the midsection 'u band' you can see on the plot.

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

채택된 답변

Image Analyst
Image Analyst 2016년 1월 7일
You can create an image where you place a dot (set a pixel to a value of 1) wherever there is a data point. If the pixel is already set, then add 1 to the pixel value. Then you can scan it with a moving window with conv2() to count the dots in the window and find out where the count is less than some number. For example (untested)
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 long g;
format compact;
fontSize = 20;
% Create random data.
numPoints = 100000;
x = rand(1,numPoints);
y = rand(1, numPoints);
scaleFactor = 1000; % Adjust depending on the range of x and y.
% Aim to have rows and columns be around a thousand or so.
rows = ceil(max(y) * scaleFactor);
columns = ceil(max(x) * scaleFactor);
% Allocate empty array - no counts at all.
dotImage = zeros(rows, columns);
% Place dots in proper locations on our dot image.
for k = 1 : length(x)
row = ceil(scaleFactor * y(k));
col = ceil(scaleFactor * x(k));
dotImage(row, col) = dotImage(row, col) + 1;
end
subplot(2,2,1);
imshow(dotImage, []);
title('Dots Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Now count the dots in a 11-by-11 moving window
filterWindow = ones(11);
countsImage = conv2(dotImage, filterWindow, 'same');
subplot(2,2,2);
imshow(countsImage, []);
title('Counts Image', 'FontSize', fontSize, 'Interpreter', 'None');
% 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')
% Let's compute and display the histogram.
[pixelCount, grayLevels] = hist(countsImage(:), 30);
subplot(2, 2, 3);
bar(grayLevels, pixelCount); % Plot it as a bar chart.
grid on;
title('Histogram of counts image', 'FontSize', fontSize, 'Interpreter', 'None');
xlabel('Gray Level', 'FontSize', fontSize);
ylabel('Pixel Count', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
% Find out where the counts in the window is less than 50.
lowCountsImage = countsImage < 7;
subplot(2,2,4);
imshow(lowCountsImage, []);
title('Low Counts Map', 'FontSize', fontSize, 'Interpreter', 'None');
  댓글 수: 10
jgillis16
jgillis16 2016년 1월 8일
편집: jgillis16 2016년 1월 8일
I adjusted the scale factor, but it seems that I left out a constant to multiply GalList.dec1 originally by, but the min is -89.3346 and max is 89.3464. I understand the scale factor issue, but now we face the problem that the min value is less than zero...
Could we possibly just adjust the following piece of code:
GalList.dec1 = GalList.dec;
to the following?
GalList.dec1 = GalList.dec + 90;
Now, with the scale factor set to 5, the search was 'too' refined. But, I had another question on explicitly what the moving window does? For example, what does it mean when I increase the window from an 11x11 to a 30x30?
jgillis16
jgillis16 2016년 1월 8일
And, (sorry again for all the questions!) how would I convert back to the x,y coordinates from the pixel values? I would like to have essentially a text output of all the sparse regions associated with the low counts image in an 'x,y value' format.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 1월 7일
Or you could do a 2D histogram.
I do not understand what you mean by 5 objects per degree in reference to a 2D plot: that would only make sense to me if you had a fixed origin point and you were more or less doing a radon transform.
  댓글 수: 1
jgillis16
jgillis16 2016년 1월 7일
Now, my end goal (Walter this might help clarify the original question as well) is to impose a number (a correction in a sense) to the identified areas on the graph that fall below the galaxy threshold.
So what I mean is that, for example, I should know that in the sections of 100-150 on the x axis and -40 to -60, I should multiply the data set by that number.
Hope it's clear, and thanks again guys.

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

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by