logo
down
shadow

Color correcting images in MATLAB


Color correcting images in MATLAB

By : user2949595
Date : November 17 2020, 01:00 AM
wish helps you @sepdek below pretty much suggested the method that @NKN alluded to, but I will provide another approach. One more alternative I can suggest is to perform a colour correction based on a least mean squared solution. What this alludes to is that we can assume that transforming a pixel from im2 to im1 requires a linear combination of weights. In other words, given a RGB pixel where its red, green and blue components are shaped into a 3 x 1 vector from the corrupted image (im2), there exists some linear transformation to get its equivalent pixel in the clean image (im1). In other words, we have this relationship:
code :
[R_im1]       [R_im2]
[G_im1] = A * [G_im2]
[B_im1]       [B_im2]

  Y     = A *   X
close all;
clear all;
im1 = imread('http://i.stack.imgur.com/GtgHU.jpg');
im2 = imread('http://i.stack.imgur.com/wHW50.jpg');

rng(123); %// Set seed for reproducibility
num_colours = 2000;
ind = randperm(numel(im1) / size(im1,3), num_colours);

%// Grab colours from original image
red_out = im1(:,:,1);
green_out = im1(:,:,2);
blue_out = im1(:,:,3);

%// Grab colours from corrupted image
red_in = im2(:,:,1);
green_in = im2(:,:,2);
blue_in = im2(:,:,3);

%// Create 3 x N matrices
X = double([red_in(ind); green_in(ind); blue_in(ind)]);
Y = double([red_out(ind); green_out(ind); blue_out(ind)]);

%// Find A
A = Y*(X.')/(X*X.');

%// Cast im2 to double for precision
im2_double = double(im2);

%// Apply matrix multiplication    
out = cast(reshape((A*reshape(permute(im2_double, [3 1 2]), 3, [])).', ...
          [size(im2_double,1) size(im2_double,2), 3]), class(im2));
names = {'Red', 'Green', 'Blue'};
figure;
for idx = 1 : 3
    subplot(3,2,2*idx - 1);
    imhist(im1(:,:,idx));
    title([names{idx} ': Image 1']);
end

for idx = 1 : 3
    subplot(3,2,2*idx);
    imhist(out(:,:,idx));
    title([names{idx} ': Output']);
end


Share : facebook icon twitter icon
Superimpose images MATLAB(grey with color)

Superimpose images MATLAB(grey with color)


By : codehit
Date : March 29 2020, 07:55 AM
Does that help I have two matrices, the first is the ROI from an dicom image (grey scale) and the second is a matrix with values between 0-1. , How about
code :
figure;
imshow( first(:,:,[1 1 1]) ); % make the first a grey-scale image with three channels so it will not be affected by the colormap later on
hold on;
t_second = second .* ( second >= .6 & second <= 1.0 ); % threshold second image
ih = imshow( t_second );
set( ih, 'AlphaData', t_second );
colormap jet
Correcting non-uniform illumination on light background - matlab

Correcting non-uniform illumination on light background - matlab


By : user1996588
Date : March 29 2020, 07:55 AM
Hope that helps You could use a technique called Adaptive Thresholding, or alternatively use the Triangle Method for thresholding.
Also, if you substract the background from itself, of course you get black! Indeed, you want to substract the amount of blackness, which is 1-x with x the pixel value (or 255-x in the case of integer image).
code :
newimage = 1 - ((1-oldimage)-(1-background));
Overlaying Images in MATLAB with different color channel

Overlaying Images in MATLAB with different color channel


By : user3464410
Date : March 29 2020, 07:55 AM
wish help you to fix your issue In MATLAB, an RGB image is saved as m by n by 3 array, where m and n are the height and width of the image. The image parts are thus:
code :
rgbImage(:,:,1) = redImage;
rgbImage(:,:,2) = greenImage;
rgbImage(:,:,3) = blueImage;
rgbImage(:,:,3) = blueImage;
rgbImage(:,:,2) = greenImage;
rgbImage(:,:,1) = redImage;
Why do I get different color images using the same MATLAB code?

Why do I get different color images using the same MATLAB code?


By : michaellewis
Date : March 29 2020, 07:55 AM
This might help you Your friend is using R2014b or later where the default colour map is the parula colour map. The results you have previously are using the default colour map before R2014b, which is the jet colour map. As mentioned in the documentation regarding the default colour map:
code :
colormap jet;
Adding Color Maps to images in MATLAB

Adding Color Maps to images in MATLAB


By : Feather_Fighter
Date : March 29 2020, 07:55 AM
I wish this helpful for you The syntax that you're using is colorbar(target). According to the documentation, target is:
code :
colorbar;
colorbar(gca);
saveas(gca, 'barabara_withMAP.png')
Related Posts Related Posts :
  • how to covert 1/4 elements of a matrix to zero
  • Generating smaller video file size from frames
  • Difference between fspecial('sobel') and edge(i,'sobel') matlab
  • Insert a new line in listbox on Matlab GUIDE
  • creating url with sprintf creates wrong url
  • How to plot multiple figures in a for loop in matlab
  • Matlab allow access to folder for mkdir
  • How can I order items in a Matlab legend via the figure editor?
  • averaged phase shift between two noisy signals
  • MATLAB: Failed to correctly write using csvwrite()
  • Matlab: directly access a specific return value of functions
  • How to apply a polynomial to a sequence
  • Anonymous Function with changing array size
  • How to represent double type number in binary form?
  • increase / decrease the frequency of a signal using fft and ifft in matlab / octave
  • How to calculate distance between two set of coordinates in meter?
  • multiple colorbar in ocatve
  • how to alter the range of values of a plot generated by spectrogram function
  • How do I transform a column of data into a normal distribution in MATLAB?
  • Matlab Not enough input arguments
  • Unable to print character value received on serial port in Matlab
  • Blocking Ctrl-C / Ctrl-Z in an input command
  • Find all mappings between two binary vectors of same size?
  • Questions about lowpass filters using 'butter' function in Matlab
  • Nested Bluetooth callback in Matlab GUI
  • How to select random numbers from a given list in matlab / octave
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org