0

I am working on a project where I need to extract each cell in a table in a latex file. So I am coloring each of the cell with different color so that when I parse the png image of the file then I should get different colour for each of the cell. But I am getting slightly different color in both the cases. My Latex code is

\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{tabular}{l}
    \cellcolor[RGB]{100,150,200}
\end{tabular}
\end{document}}

When I parse the file using opencv then I get the following colors. [(255, 255, 255), (235, 224, 214), (198, 156, 115), (199, 149, 98), (18, 18, 18)] My python script is

import numpy as np
import cv2
from PIL import Image
file_name = 'rough-1.png'
img = cv2.imread(file_name)
lst = []
for i in range(img.shape[0]):
    for j in range(img.shape[1]):
        if(tuple(img[i,j]) not in lst):
            lst.append(tuple(img[i,j]))
print(lst)
  • If you uncompress your PDF and open it with a text editor, the colour is 0.39215 0.58823 0.7843 rg which matches your input. So your problem must lie in how you are converting from PDF to PNG or how you are parsing the PNG, not with LaTeX. – David Purton Jun 13 '19 at 12:50
  • Please what is "opencv"? – Mensch Jun 23 '19 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.