필터 지우기
필터 지우기

Error while using JBIG compression.

조회 수: 5 (최근 30일)
Manikandan VM
Manikandan VM 2017년 3월 7일
댓글: Pengfei 2023년 3월 19일
I need to compression a binary image(matrix of size RxC) in a lossless manner. For this I hope I can use JBIG compression, and I have downloaded the toolbox from the following link.
https://in.mathworks.com/matlabcentral/fileexchange/5104-toolbox-wavelets/content/toolbox_wavelets/perform_jbig_coding.m
I added the extracted folder to Matlab path, and I tried to call the perform_jbig_coding function in the following way
[y, nbr_bits]=perform_jbig_coding(x);
please note that x I defined as a random binary matrix of size 256x256 bits.
But while using this I am getting the following error :
_ _ 'pbmtojbg' is not recognized as an internal or external command, operable program or batch file. Error using perform_jbig_coding (line 22) Unable to open Jbig file.__
Anyone can help me to resolve this error? or Anybody can share the JBIG pure matlab code for compression and decompression?
  댓글 수: 1
Pengfei
Pengfei 2023년 3월 19일
Hello, have you implemented JBIG compression and decompression? I am currently struggling with these two issues

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

답변 (1개)

Alejandro Peñuelas
Alejandro Peñuelas 2020년 5월 24일
Hi. Probably it is too late but this answer could be useful for other Matlab users.
Specifically for this situation, inside the function that you mentioned, the code calls two external programs 'pbmtojbg.exe' and 'jbgtopbm.exe'. The header of the function says: "It requires pbmtojbg and jbgtopbm executable." that can be generated running the make fine contained in the JBIG-KIT library that can be found at: JBIG-KIT.
Instructions to generate those executables can be found at: JBIG-KIT Instructions.
I hope this information can help someone and, if you need help, you can ask anything. This process helped me to use the jbigkit library and the mentioned function in my matlab projects.
  댓글 수: 6
sahil sharma
sahil sharma 2023년 2월 10일
clear;
clc;
I = double(imbinarize(im2gray(imread("original.jpg"))));
[y,nbr_bits] = perform_jbig_coding(I);
I am just calling the function and I am getting this error:
zsh:1: command not found: pbmtojbg
Error using perform_jbig_coding
Unable to open Jbig file.
Error in Main (line 4)
[y,nbr_bits] = perform_jbig_coding(I);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Main is the file name calling the perform_jbig_coding function.
I have saved all the function in a same folder: Main.m, perform_jbig_coding.m, jbgtopbm (as unix executable file) and pbmtojbg (as unix executable file)
After I run the program my image "original.jpb" is converting into b.pbm, however after that the error occurs. I am also pasting the perform_jbig_coding.m code:
function [y,nbr_bits] = perform_jbig_coding(x)
% perform_jbig_coding - perform binary image coding
%
% [y,nbr_bits] = perform_jbig_coding(x);
%
% It requires pbmtojbg and jbgtopbm executable.
%
% Copyright (c) 2006 Gabriel Peyr
name_pbm = 'b.pbm';
name_jbg = 'c.jbg';
if size(x,1)>1 && size(x,2)>1
% forward transform
% save as pbm
imwrite(rescale(x), name_pbm, 'pbm');
% convert to jgib
!pbmtojbg tmp.pbm tmp.jbg
% read jbig file
fid = fopen(name_jbg);
if fid<0
error('Unable to open Jbig file.');<== It is here my program is ending
end
[y,cnt] = fread(fid, Inf);
fclose(fid);
nbr_bits = length(y)*8;
% remove tmp files
!del tmp.jbg
!del tmp.pbm
else
% backward transform
fid = fopen(name_jbg, 'wb');
if fid<0
error('Unable to open Jbig file.');
end
fwrite(fid, x);
fclose(fid);
% convert to pbm
!jbgtopbm tmp.jbg tmp.pbm
% read pbm
y = imread(name_pbm);
% remove tmp files
!del tmp.jbg
!del tmp.pbm
nbr_bits = -1;
end
sahil sharma
sahil sharma 2023년 2월 10일
Also if you can remember how were you able to run the program it would be very helpful.

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

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by