colourizatin of black and white video

10 vues (au cours des 30 derniers jours)
Muhammad
Muhammad le 3 Jan 2023
Modifié(e) : DGM le 6 Jan 2023
I want a matlab code that how to colourize black and white (charli chapplin) video into coloured video. Anyone help me.
  3 commentaires
Muhammad
Muhammad le 3 Jan 2023
first we convert a black and white video into frames and then frames will be colourize and back converted into video.Do you coding for this?
DGM
DGM le 4 Jan 2023
You still haven't answered the question about how you intend to colorize the frames. It's simple to just turn the video into arbitrary colors, but I suspect that's not what you want.
For reading and writing videos, start here.

Connectez-vous pour commenter.

Réponses (3)

Walter Roberson
Walter Roberson le 4 Jan 2023
Suppose you had a black and white (grayscale) photo of an old automobile. Suppose you want to colorize the photo. Should you arbitrarily color the automobile shades of red? No! Instead you need to do illumination correction on the image and then you have to examine the intensity of the result and try to colorize it based on the idea that each different possible car color converts to a different grayscale intensity.
But it is not true that each different car color converts to a different grayscale intensity. There are only 256 different grayscale intensities (in typical use), and there are more than 256 different car colors that have been used over time.
So to get the proper color, you need to find out what colors were offered for that particular kind of car. So you have to (somehow) recognize which make and model year of car it was, and then you have to look up a database of paint colors that the model was offered in, and illumination correction, and convert that to grayscale and match the intensities against the illumination corrected photo to try to figure out which of the offered shades the car would have been.
That is a bunch of work, but theoretically possible if you had a sufficiently large input database to be able to recognize every possible year and model of car and every factory paint shade. Unfortunately some model years could only be told apart by looking at the interior details (for example details of the font style in the tachometer). And unfortunately, people get custom paint jobs. Or have dirty cars so the intensity information is pretty wrong...
Oh wait, notice the toy that kid is holding, it's clearly very new, and it was only offered in 1980. That car isn't the 1982 Canadian-sold Lada you identified it as, it is the 1976 Lada directly imported from Russia, which was offered in a different set of colors...
I would advise you to give up on this kind of project, unless you want to spend years on it, or you are willing to restrict the input images a lot, or are willing to have the results be wrong compared to what a careful expert might discover from the image.
  1 commentaire
Walter Roberson
Walter Roberson le 5 Jan 2023
You mention Charlie Chaplin.
Question for you: what is Charlie Chaplin's actual skin-tone? Not the color given to him by people who recolorized his works: his actual skin tone? There are a few rare color photos of him, such as at https://www.vintag.es/2013/08/rare-colour-portraits-of-charlie.html but those are a very old color process that has the tones pretty washed out.
Charlie Chaplin was mostly said to be English with Irish roots, and that gives hints about skin tones. But there is evidence (mother's side) and anecdotes that both his parents were half Romani, so he was likely more olive-toned than English/Irish would suggest.
But is the question about recolorizing to authentic skin tones? Because in those days strong makeup had to be used (the lighting was bright and hot because the film was not yet ready to deal with low light). So to recolorize back to what was actually present at the time of filming would be to recolorize back to the grease-paint tones...
The video you are proposing to recolorize: what information do you have about the kinds of film and kinds of cameras that were used to record them? And was the video taken from original negatives, or was the film re-recorded onto other negatives (with different color processes)? What is the re-recording technical history between the originals and the video?
If you do not have accurate information about the equipment used to record and re-record, and historic information about the optical transform functions, then you cannot hope to recreate the original color.
If your task is to put in some color rather than accurate color... then don't worry about it, just pick some random color palette. Make him leaf green with a Barney Purple hat for example.

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 4 Jan 2023
Sounds like you might want "colorization by scribbling" Google it
or try this first hit:
  4 commentaires
Image Analyst
Image Analyst le 5 Jan 2023
Not sure how you want to do that. How about if you hand draw some region on the image and then change the hue? So get the regions, convert the image to HSV color space. Convert the hue to some value that you want, then convert back to RGB color space.
Attached are some drawing demos.
I can't spend the time to do your full project for you. About all I can do is to give you directions like I just did and then let you code up your project.
Here's start. First get your mask from drawing.
% Convert to HSV color space
hsvImage = rgb2hsv(rgbImage);
[h, s, v] = imsplit(hsvImage);
h(mask) = someNewValue between 0 and 1
hsvImage(:, :, 1) = v;
% Convert back.
rgbImage2 = hsv2rgb(hsvImage);
imshow(rgbImage2);
DGM
DGM le 6 Jan 2023
Modifié(e) : DGM le 6 Jan 2023
I think you meant
hsvImage(:, :, 1) = h;
... but substituting/replacing H won't colorize the input.
% input frame
% i'm using an actual video frame instead of expanding cameraman.tif
% since this is already a nominally-grayscale compressed color image
inframe = imread('inframe.png');
% the region color
localcolor = [100 50 0]/255;
% convert to HSV
hsvcolor = rgb2hsv(localcolor);
hsvframe = rgb2hsv(inframe);
% substitute H
hsvframe(:,:,1) = hsvcolor(1);
% convert back to RGB
outframe = hsv2rgb(hsvframe);
imshow(outframe)
You can get some colorization with HS substitution in HSV
% input frame
inframe = imread('inframe.png');
% the region color
localcolor = [100 50 0]/255;
% convert to HSV
hsvcolor = rgb2hsv(localcolor);
hsvframe = rgb2hsv(inframe);
% substitute HS
hsvframe(:,:,1) = hsvcolor(1);
hsvframe(:,:,2) = hsvcolor(2);
% convert back to RGB
outframe = hsv2rgb(hsvframe);
imshow(outframe)
... but you're restricted to half the actual brightness range unless you modulate S as a function of input V, which is basically a roundabout way of reinventing HSL. That said, any good attempt based on the film response probably isn't going to be strictly preserving brightness anyway, so it's already a deep rabbit hole.

Connectez-vous pour commenter.


DGM
DGM le 6 Jan 2023
Modifié(e) : DGM le 6 Jan 2023
Since this is going nowhere fast, I'll just take it one step past nowhere to illustrate the point. Here is an example showing static colorization of a 4 second video. At the very least, this demonstrates the process of reading, manipulation, and writing of video frames.
invid = VideoReader('TIMwalk_halfscale.avi');
outvid = VideoWriter('recolored.avi');
% set start and end time (s)
timerange = [0 4.2];
outvid.FrameRate = invid.FrameRate;
sz = [invid.Height invid.Width 3];
% a static color image generated by some means
cpict = lingrad(sz,[0 0; 1 1],[[0.6 0.3 1]*0.5; 1 0.6 0.3]*255,'linear');
% load dummy image to set axes and create image object
hi = imshow(zeros(sz));
% process frames
invid.CurrentTime = timerange(1);
open(outvid);
while invid.CurrentTime <= timerange(2)
thisframe = readFrame(invid); % read the frame
% colorize by luma substitution
%thisframe = imblend(thisframe,cpict,1,'luma');
% colorize by luma-corrected HS substitution in HSL
thisframe = imblend(cpict,thisframe,1,'color');
% colorize by chroma-limited CH substitution in SRLAB2
%thisframe = imblend(cpict,thisframe,1,'colorlchsr');
writeVideo(outvid,thisframe); % write the frame
hi.CData = thisframe; % update display
pause(1/invid.FrameRate);
end
close(outvid);
This is a sample input frame
This is the static color source for all frames
This is the colorized output frame
Does it make sense that all frames are colorized based on a static source? Probably not, so that leaves the question as to how much work you want to invest in either manually colorizing each frame or writing some AI that will guess on your behalf.
In the above example, the color source does not change, so it goes outside the loop. If you have a means of getting color information for each frame, then that process will go somewhere inside the loop instead.
As in the link I provided earlier, there are three options shown for colorizing the frame, from fastest to slowest. Simple luma substitution tends to cause contrast reduction, and chroma truncation in LAB or SRLAB is slow. Pick a method or feel free to use a different one entirely.
The tools lingrad() and imblend() are from MIMT, which can be found on the File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by