all sky camera image to graph (x,y) distance vs intensity

조회 수: 3 (최근 30일)
Hasnaa Hossam
Hasnaa Hossam 2022년 11월 4일
답변: Satyam 2025년 6월 4일
I have image from all-sky camera and I need to convert it into graph ( distance: latitude and longitude vs Intenisty) in oder to do other oprations then on it.
Note: This is photo only to illustrate a type of image.
this is taken from online open sourses.

답변 (1개)

Satyam
Satyam 2025년 6월 4일
Hi Hasnaa,
A graph of Latitude and Longitude vs. Intensity is required from the all-sky camera image. The process begins by identifying the center of the circular image. Next, pixel coordinates (x, y) are converted to polar coordinates (r, θ) relative to this center. Grayscale pixel values are then used to represent intensity.
To plot the graph, leverage the use of ‘scatter3’ plot function. Refer to the documentation to learn about the syntax: https://www.mathworks.com/help/matlab/ref/scatter3.html
Below is a sample code depicting the above approach.
% Step 1: Load and preprocess image
img = imread('image.jpeg');
gray = rgb2gray(img); % Convert to grayscale if not already
% Get image size
[H, W] = size(gray);
cx = W / 2; % Image center X
cy = H / 2; % Image center Y
r_max = min(cx, cy);
% Step 2: Create meshgrid for image
[x, y] = meshgrid(1:W, 1:H);
% Center the coordinates
x_centered = x - cx;
y_centered = y - cy;
% Convert Cartesian image coords to polar coords (r, θ)
r = sqrt(x_centered.^2 + y_centered.^2) / r_max;
theta = atan2(y_centered, x_centered);
% Mask to keep only valid circular region (within all-sky dome)
mask = r <= 1;
% Convert to elevation (0 at horizon, π/2 at zenith)
elevation = (1 - r) * (pi / 2);
azimuth = mod(theta, 2*pi);
% Step 3: Convert azimuth and elevation to lat/lon (assuming zenith is (0,0))
latitude = rad2deg(elevation);
longitude = rad2deg(azimuth);
% Step 4: Extract intensity values
intensity = double(gray); % Convert to double for processing
intensity(~mask) = NaN; % Mask out-of-sky pixels
% Optional: Downsample for visualization
sample_step = 5;
lat_sample = latitude(1:sample_step:end, 1:sample_step:end);
lon_sample = longitude(1:sample_step:end, 1:sample_step:end);
int_sample = intensity(1:sample_step:end, 1:sample_step:end);
% Step 5: Plot
figure;
scatter3(lon_sample(:), lat_sample(:), int_sample(:), 10, int_sample(:), 'filled');
xlabel('Longitude (Azimuth °)');
ylabel('Latitude (Elevation °)');
zlabel('Intensity');
title('All-Sky Image: Latitude/Longitude vs Intensity');
colorbar;
I hope this answer solves the query.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by