Files
labs-information-security/lab6-steganography/modes/extract_mode.py
T
2026-07-12 14:06:45 +04:00

39 lines
1.1 KiB
Python

from __future__ import annotations
from dataclasses import dataclass
from typing import Dict
from entities.rgb_image512 import RgbImage512
from entities.label64 import Label64
from entities.sequence8 import Sequence8
from steg.embedder import Embedder
from steg.extractor import Extractor
from steg.component_pipeline import ComponentPipeline
@dataclass
class ExtractMode:
"""CLI-режим извлечения метки из изображения."""
def run(
self,
input_path: str,
output_path: str,
channel: str,
seq0: str,
) -> Dict[str, str]:
"""Извлечь метку и сохранить 64x64 PNG."""
rgb = RgbImage512.from_file(input_path)
seq = Sequence8.from_string(seq0)
pipeline = ComponentPipeline(channel=channel, embedder=Embedder(), extractor=Extractor())
label: Label64 = pipeline.extract_from_rgb(rgb, seq)
label.to_image(output_path)
return {
"status": "ok",
"output": output_path,
"channel": channel,
"seq0": seq0,
}