# How to take the color grade from one image and apply it to another?

조회 수: 3 (최근 30일)
Joey Daermann 2022년 11월 28일
편집: DGM 2022년 11월 28일
Good Afternoon all,
I was wondering if its possible to take the colors of one image and apply them to another. I want to bascailly convert the theme.
Ive seen this done many times in photoshop for example in this video https://www.youtube.com/watch?v=epPOrHG6SnE .
What steps would i go about doing this in matlab if at all possible? Has anyone done this before?
Thank you all.

댓글을 달려면 로그인하십시오.

### 채택된 답변

Image Analyst 2022년 11월 28일
Sorry but I don't think Walter's suggestion would work.
The best paper I've seen on this is
Sorry but I don't have code for that paper.
##### 댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
Image Analyst 2022년 11월 28일
편집: Image Analyst 2022년 11월 28일
I made a stab at doing what he said but I only got partway until I got into some pretty complicated math for gamut warping that I didn't know to do in MATLAB.
Uh, yeah. 😬
DGM 2022년 11월 28일
편집: DGM 2022년 11월 28일
Yeah, same. I didn't get very far either. It's still in my TODO notes ... waaay down at the bottom.

댓글을 달려면 로그인하십시오.

### 추가 답변 (2개)

Walter Roberson 2022년 11월 28일
rgb2ind the base image and save the color map. Now rgb2ind the second image and ind2rgb passing in the saved colormap.
##### 댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
Walter Roberson 2022년 11월 28일
the task is not well defined.
Suppose you took a 3d histogram of HSV. Sort by popularity. Create a cumulative sum so that given a fraction you can look up its associated color bin.
Now take the second image, so the same thing.
Now take the cumulative relative fractions in the second image and look them up against the first image's information to determine an hsv bin. Invert linear bin to hsv value.
If the first image was, for example, mostly pastel purple then the computed version of the second image would be too. However, it would definitely be subject abrupt transitions.
Walter Roberson 2022년 11월 28일
I forgot earlier that you can rgb2ind your base image and then rgb2ind the second image passing in the colormap from the first image and then ind2rgb back with the same map. The effect would be to substitute each color with the closest color that exists in the first image. But it does not have to appear much in the original image so this would not tend to shift palettes.

댓글을 달려면 로그인하십시오.

DGM 2022년 11월 28일
편집: DGM 2022년 11월 28일
The paper that @Image Analyst linked is good, but I haven't seen any MATLAB implementation. You're free to post it on the File Exchange if you write one.
MIMT imrecolor() is about the closest thing, but it's nowhere near as good as that. Results may end up pretty terrible on photographs, but it was never meant to work on anything but abstract images. It's just an incremental improvement over a basic histogram matching as one would do with imhistmatch().
I wouldn't call it a color grading tool, but I might as well throw that out there. This comment references the paper that @Image Analyst linked and compares to the results using imrecolor() and imhistmatch().

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by