How can I change phase image to gray code?

조회 수: 6 (최근 30일)
Lukasz Sarnacki
Lukasz Sarnacki 2022년 8월 22일
편집: Walter Roberson 2023년 8월 31일
name = ['C:\Users\User\Desktop\trail.jpg'];
im = imread(name); im = im(:,:,2);
im= im2double(im);
imbin = imbinarize(im);
imbin = qammod(imbin,4,'gray'); %this part doesn't work
I tried to use function bin2gray, but it didn't work anymore. Any other alternatives failed me. My only option is doing it mannualy by if but I know this is reallby bad solutions for this problem. (30 000 000 iterations).
This is theoretical scheme how to do it. I have 6 images with fringes.
My error log
Error using qammod
Expected input number 1, X, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was logical.
Error in qammod>validateInput (line 262)
validateattributes(x, {'numeric'}, {'real','integer','>=',0,'<',M}, mfilename, 'X', 1);
Error in qammod (line 94)
validateInput(x, M, bitInput, outputDataType);
Error in zad2 (line 24)
imbin = qammod(imbin,4,'gray');
  댓글 수: 3
Lukasz Sarnacki
Lukasz Sarnacki 2022년 8월 23일
I have added it. Can you help me now?
Image Analyst
Image Analyst 2022년 8월 24일
No. Maybe someone else can. I don't have the Communications toolbox that qammod is in.

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

답변 (2개)

VINAYAK LUHA
VINAYAK LUHA 2023년 8월 31일
편집: Walter Roberson 2023년 8월 31일
Hi Lukasz,
As per my understanding, the issue is due to type mismatch between the formal and actual parameters that the “qammod” function takes.
Use the “im2double” function to typecast the matrix “imbin” from logical to double type prior to calling the “qammod” function to resolve the type mismatch error.
Here’s the documentation of “im2double” for your reference.
I hope it helps!

Walter Roberson
Walter Roberson 2023년 8월 31일
편집: Walter Roberson 2023년 8월 31일
name = 'trial1.jpg';
im = imread(name);
if ndims(im) > 2; im = im(:,:,2); end
im= im2double(im);
imbin = double(imbinarize(im));
imbin = qammod(imbin,4,'gray');
whos
Name Size Bytes Class Attributes ans 1x35 70 char cmdout 1x33 66 char im 1920x1080 16588800 double imbin 1920x1080 33177600 double complex name 1x10 20 char
imagesc(real(imbin)); title('real'); colorbar
imagesc(imag(imbin)); title('imag'); colorbar
That particular file is an example of a rare grayscale JPEG image, so you have to be careful how you read it.
Note that imbinarize() converts each location to either false (less that the threshold) or true (greater than the threshold), which is an alphabet of size 2. You are asking for qammod to process it as if it were an alphabet of size 4. That will work, but it is a bit inefficient.

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by