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 :

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 01. , How about code :
figure;
imshow( first(:,:,[1 1 1]) ); % make the first a greyscale 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 nonuniform illumination on light background  matlab
By : user1996588
Date : March 29 2020, 07:55 AM

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?
By : michaellewis
Date : March 29 2020, 07:55 AM

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 :
