[Octave] Image Processing : Pixel Transformation and Quality Picture.
Afficher commentaires plus anciens
Hello everyone,
I'm still on the modeling of gravitational lensing. I intended to proceed in a different method. Let me explain.
I intend to take a picture, for example, a sky with a galaxy. And model the image by a matrix. This matrix would actually be of size N * M (where N is the pixel length of the image and M, the width) Each pixel would therefore a number of the matrix.
I have two perspectives:
First, create a map as modeling the geometric changes applied to our image (to represent the bending of light rays) and then apply to the image.
The second, operate directly on the image without using a tier modeling.
My result should look like this:
A=imread('galaxy.jpg')
% Liste des Variables
[nr,nc]= size([A])
x1=y1=500 % Position de la masse défléctrice
R= 1 %Rayon de la masse déflectrice (exemple de trou noir = 1 pixel)
largeur = nc %largeur de l'image
longeur = nr %longueur de l'image
Ralpha=(sqrt((x-x1).^2+(y-y1).^2))
L=(4.*G*M)./(c^2)
% Les Constantes
G= 6.67e-11
c=3.0e+8
M= 1,7e+38 %Masse de la masse déflectrice
z2 = 9,5e+15 %Distance de la masse par rapport à la galaxie
z1= 2,75e+22 %Distance par rapport à la Terre
% Lentille gravitationnelle
B=[]
for i=1:largeur
for j= 1:longueur
if sqrt((x-x1).^2+(y-y1).^2)<=R:
A(i,j)= 0 % pixel noir
if sqrt((x-x1).^2+(y-y1).^2)>R:
x[i]=i+z2.*((i./z1)-(L/R).*i/R)
y[j]=j+z2.*((j./z1)-(L/R).*j/R)
A(i,j)=B(x[i],y[j])
imread(B)
end
% code
I tried to do it for transformations. If i try to change A(i,j) to A(x4,y4) i will change the original pixel wich locate in (x,y) but when the programm will go to A(x4,y4) throught i,j coordonate. The pixel itself has already been moved, it will not change the original pixel but the pixel from (i, j) already transformed. So how can we apply transformations while telling it not to apply transformations on the transformed pixel but the original pixel in this position previously. Here i try to create an other matrix B which contains all transformation (or value pixel with relocation).
Next problem : Quality picture:
If i apply these transformations in A matrix, i will lose in image quality? Because when i transformed my image in A matrix, Octave noticed that :
"Warning : Your Version of GraphicsMagick limits images to 8 bits per pixel"
That's why i would like to know if it could be better to call the image in an other way to keep the original quality picture. But if i must do that, i don't know how... :/
Excuse me for my expression, but i'm not english.
Thx in Advance
2 commentaires
Andrew Sol
le 23 Juin 2024
Same problem. Doy you solve it?
DGM
le 23 Juin 2024
There are a bunch of things in this code which don't make any sense in MATLAB. I don't know if they do in Octave, but either way, there are missing and unused variables here. There are a handful of redundant and useless operations being performed, and it appears that the code is modifying the source image, which destroys its ability to actually do what it's trying to do (whatever that is).
Unless there's some specific reason to revive an old Octave implementation, I wouldn't try to fix this. I'd back up and start with a clearer explanation of what's trying to be done -- primarily, how you're defining the relationship between image coordinates and physical coordinates, because gravity doesn't know anything about the size of pixels. If this is just some pixel displacement operation, it could all amount to something that could be done with a single call to interp2().
Réponses (0)
Catégories
En savoir plus sur Ceramics dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!