all sky camera image to graph (x,y) distance vs intensity
4 views (last 30 days)
Show older comments
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.

0 Comments
Answers (1)
Satyam
on 4 Jun 2025
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.
0 Comments
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!