Azzera filtri
Azzera filtri

How can I change phase image to gray code?

7 visualizzazioni (ultimi 30 giorni)
Lukasz Sarnacki
Lukasz Sarnacki il 22 Ago 2022
Modificato: Walter Roberson il 31 Ago 2023
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 Commenti
Lukasz Sarnacki
Lukasz Sarnacki il 23 Ago 2022
I have added it. Can you help me now?
Image Analyst
Image Analyst il 24 Ago 2022
No. Maybe someone else can. I don't have the Communications toolbox that qammod is in.

Accedi per commentare.

Risposte (2)

VINAYAK LUHA
VINAYAK LUHA il 31 Ago 2023
Modificato: Walter Roberson il 31 Ago 2023
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 il 31 Ago 2023
Modificato: Walter Roberson il 31 Ago 2023
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.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by