How can I change phase image to gray code?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1104205/image.png)
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');
Risposte (2)
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!
0 Commenti
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
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.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!