Red, Green, Blue Full image pattern file's RGB value distortion when patterns was saved to jpg file form.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
JUNHYEONG KIM
il 15 Feb 2023
Commentato: JUNHYEONG KIM
il 20 Feb 2023
Hello,
I met the problem that is RGB full image pattern file's RGB value distortion at jpg file.
I want to make the specific color box pattern that have background and center box. and this file must be jpg file.
but when I run this code to make perfect red pattern(255, 0, 0) and verify this is right color,
the red pattern file had RGB value of (254, 0, 0) .
Could you tell me how to generate perfect red(255,0,0 / jpg file)?
also I try to imwirte(img, filename, 'Quality', 100), however this problem was not cleared.
and equally if I make perfect green and blue, this green have (0, 255, 1) / blue have (0, 0, 254).
Please, Note below the function code:
function value = fullimage(image_values, V, H)
for i = 1: size(image_values, 1)
% CSV 파일 내 데이터를 한 줄씩 가져오는 작업
image_values_row = image_values(i,1:7); %수정 Point2
% CSV 파일 내 한 줄의 데이터 내에서 각 필요한 데이터를 하나씩 추출
R = image_values_row(1); %R value of RGB
G = image_values_row(2); %G value of RGB
B = image_values_row(3); %B value of RGB
BS = image_values_row(4);
BGR = image_values_row(5); %Back ground R value of RGB
BGG = image_values_row(6); %Back ground G value of RGB
BGB = image_values_row(7); %Back ground B value of RGB
% CSV 파일 내 색상 RGB 값을 통해 BackGround에 RGB값 지정
img(1:V, 1:H, 1) = BGR/255;
img(1:V, 1:H, 2) = BGG/255;
img(1:V, 1:H, 3) = BGB/255;
% Box size에 따라 내부에 Box가 생성되도록 하는 수식, 양의 정수 범위어야함.
Vbox1 = round(V/2-sqrt(BS)/20*V)+1;
Vbox2 = round(V/2+sqrt(BS)/20*V)+1;
Hbox1 = round(H/2-sqrt(BS)/20*H)+1;
Hbox2 = round(H/2+sqrt(BS)/20*H)+1;
% CSV 파일 내 색상 RGB 값을 통해 Box에 RGB값 지정
img(Vbox1:Vbox2, Hbox1:Hbox2, 1) = R/255;
img(Vbox1:Vbox2, Hbox1:Hbox2, 2) = G/255;
img(Vbox1:Vbox2, Hbox1:Hbox2, 3) = B/255;
%이미지 저장
filename = sprintf('image%d.jpg',i);
imwrite(img,filename);
end
end
2 Commenti
Angelo Yeo
il 16 Feb 2023
문제를 재현할 수 있도록 예시 파일과 예시 스크립트를 올려주실 수 있으실까요? 함수 스크립트만 가지고는 어떤 이슈인지 정확히 알기 어렵습니다.
Risposta accettata
Angelo Yeo
il 16 Feb 2023
imwrite(img,filename,'mode','lossless')
4 Commenti
Angelo Yeo
il 16 Feb 2023
Modificato: Angelo Yeo
il 16 Feb 2023
작성해주신 예시 스크립트를 수정해보면 정상적으로 255 값이 저장되는 것을 알 수 있습니다.
% setting Horizontal, Vertical pixels
H = 1920;
V = 1080;
R = 255;
G = 0;
B = 0;
% Setting RGB Value
img(1:V, 1:H, 1) = R/255;
img(1:V, 1:H, 2) = G/255;
img(1:V, 1:H, 3) = B/255;
% Save image
filename = sprintf('image1.jpg');
imwrite(img,filename,'mode','lossless')
a = imread('image1.jpg');
a(1,1,1)
위의 스크립트가 사용하시는 MATLAB 환경에서 동작하는지 우선 확인 부탁드립니다. "죄송합니다. 현재 지원되지 않는 형식이거나 파일이 손상되었기 때문에 사진을 열 수 없습니다"와 같은 에러가 발생하는 이유는 다른 원인에 의한 것은 아닐까요?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su 영상 필터링 및 향상 in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!