-
Notifications
You must be signed in to change notification settings - Fork 0
color_adjust
Color adjustment module with various functions including RGB conversion
import image_processing as imp
from image_processing import im_processing,color_adjustGenerates a intensity plot
- Input:
- img:: image nd numpy array. Must be gray scaled. If not, autonomously done
- resize:: resizing factor. Float in range [0,1] or can be None for no image resize. Matplotlib surface function is very computationally expensive and resizing is strongly suggested.
- cmap:: matplotlib cmap ['viridis', 'plasma', 'inferno', 'magma', 'cividis']
- Input:
- view:: 1x2 array,list,tuple - (vertical axis angle of rotation, horizontal axis angle of rotation)
- title:: img title
- figsize = figure size
- plot:: plot figure
- Output:
- Intensity plot
>> img = im_processing.cv_read('images/img_1.jpg','RBG') #load RGB
>> color_adjust.intensity_plot(img,resize=.5).show(view=(70, 10)) #will automatically gray scale and then plot pixels
Image must be 2D grey scale... Gray Scaling...
Resizing (491, 640)....... New Shape (245, 320)Below are image intensity plot examples
.... and some fast fourier transform (see module) intensity plot examples
Generates an image histogram pixel intensities. An shows ratio of images above thresh.
-
Input:
- im:: gray/colored RGB image (np.array). Colored images are automatically gray scaled
- hist_density_thresh:: None. Else int in range [0, 255] that shows desired threshold
- show:: show plot
-
Output:
- histogram plot
img = im_processing.cv_read('images/img_10.jpg',color_scale='GRAY') #load RGB
color_adjust.plot_hist(img,hist_density_thresh=128) #plot hist
img = im_processing.cv_read('images/img_10.jpg',color_scale='RGB') #load RGB
color_adjust.plot_hist(img,hist_density_thresh=128) #plot hist with threshold comparison
img = im_processing.cv_read('images/img_10.jpg',color_scale='RGB') #load RGB
color_adjust.plot_hist(img) #plot hist overlapping
Convert RGB numpy array to individual Red Green and Blue Components
-
Input:
- img:: Red, Green, Blue Image as Numpy array
- precent:: img/=255.0
- to_BGR:: Tool uses openCV so the this convert to appropriate formate
-
Output:
- Red Green and Blue np array Components
ALGO:
half_percent = percent/2
for channel in image:
low_val = val at bottom half_percent of image
high_val = val at top half_percent of image
set vals > low_val = low_val
set vals < high_val = high_val
result = norm(img)
img = im_processing.cv_read('images/img_10.jpg') #load RGB defauly
R,G,B = color_adjust.color_isolation(img)Convert RGB numpy array to Gray Scale where gray = 0.2989 * r + 0.5870 * g + 0.1140 * b
- Input:
- rgb:: Red, Green, Blue Image as Numpy array
- Output:
- gray scaled image (np.array). (No more color channels)
img = im_processing.cv_read('images/img_10.jpg') #load RGB defauly
gray = color_adjust.rgb2gray(img)Convert RGB numpy array to BGR format (Commonly used for openCV format)
- Input:
- rgb:: Red, Green, Blue Image as Numpy array
- Output:
- Blue, Green, Red Image as Numpy array
img = im_processing.cv_read('images/img_10.jpg') #load RGB defauly
gray = color_adjust.rgb2gray(img)Convert RGB numpy array to YIQ format
-
Input:
- rgb:: Red, Green, Blue Image as Numpy array
- norm:: img/=255.0
-
Output:
- YIQ numpy array
img = im_processing.cv_read('images/img_10.jpg') #load RGB defauly
yiq = color_adjust.rgb2yiq(img)Convert RGB numpy array to individual Red Green and Blue Components
-
Input:
- rgb:: Red, Green, Blue Image as Numpy array
- norm:: img/=255.0
-
Output:
- Red Green and Blue np array Components
img = im_processing.cv_read('images/img_10.jpg') #load RGB defauly
R,G,B = color_adjust.color_isolation(img)Subtract individual color means and divide by a sigma (deviation)
-
Input:
- img:: Red, Green, Blue Image as Numpy array
- sigma:: variance
-
Output:
- RGB mean subtracted img
img = im_processing.cv_read('images/img_10.jpg') #load RGB defauly
mean = color_adjust.mean)subtraction(img)Simply brightening by mutiplication such that brightened img= alpha*img + beta
-
Input:
- img:: Red, Green, Blue Image as Numpy array
- alpha:: multiplicative term
- beta:: additive term
-
Output:
- RGB brightened and saturated img
Simply brightening by mutiplication based on the % of information the user is willing for image to loss to oversaturation
-
Input:
- img:: Red, Green, Blue Image as Numpy array
- max_info_lost:: float [0,1] ie .30 is 30% image saturation
- start_end:: 1x2 indexable array (tuple,list,np.array,etc.) of starting and ending alpha vals
- precision:: precision of amount of saturation
- verbose:: show alpha and oversaturation %
-
Output:
- RGB brightened and saturated img
>> img = im_processing.cv_read('images/img_10.jpg') #load RGB defauly
>> bright = color_adjust.brighten(img,alpha= 1.2)
>> auto_bright = color_adjust.auto_brighten(img,max_info_lost=.60,start_end=[.8,5],verbose=True)--
Alpha:0.80 | Loss:0.08%
Alpha:0.81 | Loss:1.11%
Alpha:0.82 | Loss:5.06%
Alpha:0.83 | Loss:10.83%
Alpha:0.84 | Loss:15.12%
Alpha:0.85 | Loss:20.94%
Alpha:0.86 | Loss:26.31%
Alpha:0.87 | Loss:30.13%
Alpha:0.88 | Loss:31.77%
Alpha:0.89 | Loss:34.42%
Alpha:0.90 | Loss:36.04%
Alpha:0.91 | Loss:38.85%
Alpha:0.92 | Loss:40.41%
Alpha:0.93 | Loss:42.12%
Alpha:0.94 | Loss:44.78%
Alpha:0.95 | Loss:46.23%
Alpha:0.96 | Loss:46.92%
Alpha:0.97 | Loss:47.46%
Alpha:0.98 | Loss:48.48%
Alpha:0.99 | Loss:49.28%
Alpha:1.00 | Loss:50.31%
Alpha:1.01 | Loss:50.58%
Alpha:1.02 | Loss:50.89%
Alpha:1.03 | Loss:51.28%
Alpha:1.04 | Loss:51.50%
Alpha:1.05 | Loss:51.76%
Alpha:1.06 | Loss:52.06%
Alpha:1.07 | Loss:52.42%
Alpha:1.08 | Loss:52.62%
Alpha:1.09 | Loss:53.05%
Alpha:1.10 | Loss:53.55%
Alpha:1.11 | Loss:53.82%
Alpha:1.12 | Loss:54.40%
Alpha:1.13 | Loss:55.05%
Alpha:1.14 | Loss:55.39%
Alpha:1.15 | Loss:56.09%
Alpha:1.16 | Loss:56.46%
Alpha:1.17 | Loss:57.21%
Alpha:1.18 | Loss:57.59%
Alpha:1.19 | Loss:57.98%
Alpha:1.20 | Loss:58.77%
Alpha:1.21 | Loss:59.18%
59.18% image over saturated
import image_processing as imp
from image_processing import im_processing,color_adjust,im_processing
img = imp.cv_read('images/einstein.jpg','RGB') #load RGB
gray= color_adjust.rgb2gray(img)
R,G,B= color_adjust.color_isolation(img)
mean = color_adjust.mean_subtraction(img)
gray_adj = color_adjust.grey_level_adjust(gray,grey_levels=100)
ims= [img,gray_adj,gray,mean,R,G,B]
titles= ["Original Image",'Grey Bit Adjustment',"Gray Scaled",'Mean Subtraction',
"Red", "Green","Blue"]
color_adjust.intensity_plot(im_processing.resize(gray,300,300)) #v
imp.im_subplot(ims,shape=[3,3],titles=titles,suptitle="Some Tools in Color_Adjust Lib") #plot img subplot for comparison