Last active
August 29, 2015 14:24
-
-
Save coldnebo/c03f12cc31261555e588 to your computer and use it in GitHub Desktop.
script for extracting the turbulence around a photo of a building.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
close all | |
% read the building picture | |
I1 = imread('IMG_5380.JPG'); | |
% correct the rotation | |
I2 = imrotate(I1, -90); | |
% crop it to the area of interest | |
I3 = imcrop(I2,[378.5 0.5 948 814]); | |
% focus on an roi to isolate just the sky from the building... | |
rp = [0 815;70 815;251 435;570 363;949 657;949 0;0 0]; | |
mask = roipoly(I3, rp(:,1)', rp(:,2)'); | |
% histeq just the sky roi... | |
I4 = roihisteq(I3, rp(:,1)', rp(:,2)'); | |
% then mask the image to remove the building part... | |
R = I4(:,:,1); | |
G = I4(:,:,2); | |
B = I4(:,:,3); | |
R(~mask) = 0; | |
G(~mask) = 0; | |
B(~mask) = 0; | |
I5 = cat(3,R,G,B); | |
% convert it to grayscale | |
BW = rgb2gray(I5); | |
% jet by itself is too broad to show the structure nicely, | |
% so I copy jet across p1 times p2 and truncate to get a 255 size color map | |
% then I just played with the value of p1 | |
p1 = 64; | |
p2 = ceil(256/p1); | |
cm = repmat(jet(p1),p2,1); | |
cm = cm(1:255,:); | |
% construct an image from it | |
I6 = ind2rgb(gray2ind(BW,255),cm); | |
% show the final enhancement grayscale with the generated colormap. | |
imshow(I6); | |
% and make sure it's in the original aspect ratio. | |
daspect([1,1,1]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses: ROIHISTEQ, Image Processing Toolbox, MATLAB
The original and enhanced images.