matzas
Badges: 1
Rep:
?
#1
Report Thread starter 6 years ago
#1
Hello,
I have a little problem with my work. I have 2 matrices G1 and G2, I have to sum these matrices (G=G1+G2). Let's take a look at 1st cell, I have 2 numbers 1023 and 1026, so the sum of 1st cell is 2049. Now i have to divide it ... I use G=G/.2, which kind of works BUT in the final G matrix in 1st cell is 10245 instead of 1024.5, is there a way to fix? Because I have no idea where is the problem.
Thank you for helping me :-)

EDIT: Sorry for not posting it in "Webmaster, Coding and Software Dev " did not see that category before
0
reply
a10
Badges: 19
Rep:
?
#2
Report 6 years ago
#2
(Original post by matzas)
Hello,
I have a little problem with my work. I have 2 matrices G1 and G2, I have to sum these matrices (G=G1+G2). Let's take a look at 1st cell, I have 2 numbers 1023 and 1026, so the sum of 1st cell is 2049. Now i have to divide it ... I use G=G/.2, which kind of works BUT in the final G matrix in 1st cell is 10245 instead of 1024.5, is there a way to fix? Because I have no idea where is the problem.
Thank you for helping me :-)

EDIT: Sorry for not posting it in "Webmaster, Coding and Software Dev " did not see that category before
You probably need to select each element from the matrix i.e. G= G1(n) + G2(n) (this is assuming it is a vector with just one row for example)

however since it is a matrix i.e. more than 1 row and 1 column you will need a loop to go round selecting elements n times and then performing the addition with each corresponding element position.
0
reply
matzas
Badges: 1
Rep:
?
#3
Report Thread starter 6 years ago
#3
It is kinds of huge matrix, it is sensor data from a camera, around 1300x1600. So you suggest to do it G(n,i)=G1(n,i)+G2(n,i)? or something like that?

Ye will try it right away, thought I could simply use G=G1+G2, since in theory it should do the same
0
reply
a10
Badges: 19
Rep:
?
#4
Report 6 years ago
#4
(Original post by matzas)
It is kinds of huge matrix, it is sensor data from a camera, around 1300x1600. So you suggest to do it G(n,i)=G1(n,i)+G2(n,i)? or something like that?
Yeah I would try that


(Original post by matzas)
Ye will try it right away, thought I could simply use G=G1+G2, since in theory it should do the same
The thing with matlab is what's so obvious to us humans is not so obvious to the program lol
0
reply
matzas
Badges: 1
Rep:
?
#5
Report Thread starter 6 years ago
#5
Ok, it worked, kind of stupid that i need 6 lines instead of 1 for only showing decimal
0
reply
a10
Badges: 19
Rep:
?
#6
Report 6 years ago
#6
(Original post by matzas)
Ok, it worked, kind of stupid that i need 6 lines instead of 1 for only showing decimal
Nice one, did you use a nested for loop? Mine's stuck and says the index is out of bounds :lol:
0
reply
matzas
Badges: 1
Rep:
?
#7
Report Thread starter 6 years ago
#7
s=size(G1);
for i=1:s(2)
for n=1:s(1)
G(n,i)=(G1(n,i)+G2(n,i))/2;
end
end

I wrote it that way.
0
reply
a10
Badges: 19
Rep:
?
#8
Report 6 years ago
#8
(Original post by matzas)
s=size(G1);
for i=1:s(2)
for n=1:s(1)
G(n,i)=(G1(n,i)+G2(n,i))/2;
end
end

I wrote it that way.
yeah that's how i wrote mine lol...

when you say s(2) do you mean size(G1) *2 or are you referring to size(G2)?
0
reply
matzas
Badges: 1
Rep:
?
#9
Report Thread starter 6 years ago
#9
Both matrices are same so I was referring to 2nd value in vector s=size(G1)

But to put this aside, I was looking why G=(G1+G2)/.2; did not work and I found out why. Well not sure why exacly not, because I was pretty sure I was supposed to write it this way, but I tried G=(G1+G2)/2; just to try everything I was able to think about and it worked, so i do not need to use these for cycles :-)
0
reply
a10
Badges: 19
Rep:
?
#10
Report 6 years ago
#10
(Original post by matzas)
Both matrices are same so I was referring to 2nd value in vector s=size(G1)

But to put this aside, I was looking why G=(G1+G2)/.2; did not work and I found out why. Well not sure why exacly not, because I was pretty sure I was supposed to write it this way, but I tried G=(G1+G2)/2; just to try everything I was able to think about and it worked, so i do not need to use these for cycles :-)
Yes , it's because you only need to use the "." when performing element operations outside of loops. Once in a loop you don't need the dot as it comes up with an error if you do use it.
0
reply
matzas
Badges: 1
Rep:
?
#11
Report Thread starter 6 years ago
#11
well, problem is that it is in no loop at all
skala_cervena = str2double(skala_cervena);
skala_zelena1 = str2double(skala_zelena1);
skala_modra = str2double(skala_modra);
skala_zelena2 = str2double(skala_zelena2);
s = system('dcraw -4 -D -T kob_85_L_14_12_2009_01.CR2');
raw = double(imread('kob_85_L_14_12_20 09_01.tiff'));
R=raw(1:2:end, 1:2:end);
B=raw(2:2:end, 2:2:end);
G1=raw(1:2:end, 2:2:end);
G2=raw(2:2:end, 1:2:end);
G=(G1+G2)/2;
few lines of my code and with the "." there was no error as well, only every cell was multipled by 10 (like if i did (G1+G2)/2*10)
0
reply
a10
Badges: 19
Rep:
?
#12
Report 6 years ago
#12
(Original post by matzas)
well, problem is that it is in no loop at all


few lines of my code and with the "." there was no error as well, only every cell was multipled by 10 (like if i did (G1+G2)/2*10)
hmm that's odd although I've never seen the bottom function before ("raw")!

I assigned a 3x3 matrix to a variable and when i type in the size function matlabs says my matrix is 3 by 1 when it's actually 3x3? :facepalm2:

I have no idea what it's doing today :lol:
0
reply
matzas
Badges: 1
Rep:
?
#13
Report Thread starter 6 years ago
#13
well if you mean the line "s = system('dcraw -4 -D -T kob_85_L_14_12_2009_01.CR2');" it basicly opens CMD and executes programm DCRAW with parameters -4 -D -T kob_85_L_14_12_2009_01.CR2. I have to use external programm with matlab because matlab cannot read RAW data, I have to transform to somemthing he can read, in this case to TIFF.
0
reply
a10
Badges: 19
Rep:
?
#14
Report 6 years ago
#14
(Original post by matzas)
well if you mean the line "s = system('dcraw -4 -D -T kob_85_L_14_12_2009_01.CR2');" it basicly opens CMD and executes programm DCRAW with parameters -4 -D -T kob_85_L_14_12_2009_01.CR2. I have to use external programm with matlab because matlab cannot read RAW data, I have to transform to somemthing he can read, in this case to TIFF.
Ahh I see, are you studying engineering btw?
0
reply
matzas
Badges: 1
Rep:
?
#15
Report Thread starter 6 years ago
#15
Biomedical Technology and Bioinformatics :-) this work is about Digital photo processing of retina.
0
reply
a10
Badges: 19
Rep:
?
#16
Report 6 years ago
#16
(Original post by matzas)
Biomedical Technology and Bioinformatics :-) this work is about Digital photo processing of retina.
oohhhh sweet, I learned a little bit about this in my maths lecture and how the eye picks up different intensity light levels
0
reply
Dima-Blackburn
Badges: 18
Rep:
?
#17
Report 6 years ago
#17
I hate MATLAB...
0
reply
matzas
Badges: 1
Rep:
?
#18
Report Thread starter 6 years ago
#18
Ye This topic is pretty interesting, the main goal for this soft is that doctors/whoever works with pictures on retina can adjust manually the picture without compromising it with unecessary white balancing, etc, basicly the whole process of transfering RAW sensor data to JPEG/TIFF or whatever you want. The soft will get RAW data, in my case Canon RAW data in *.CR2 and my goal is to make GUI in the end with options for user to set values manually or some kind of autotransfer to TIFF
0
reply
matzas
Badges: 1
Rep:
?
#19
Report Thread starter 6 years ago
#19
(Original post by Dima-Blackburn)
I hate MATLAB...
Do not get me wrong, but matlab is awesome for researchers and lab work
0
reply
a10
Badges: 19
Rep:
?
#20
Report 6 years ago
#20
(Original post by Dima-Blackburn)
I hate MATLAB...
it can be annoying sometimes... :lol:


(Original post by matzas)
Ye This topic is pretty interesting, the main goal for this soft is that doctors/whoever works with pictures on retina can adjust manually the picture without compromising it with unecessary white balancing, etc, basicly the whole process of transfering RAW sensor data to JPEG/TIFF or whatever you want. The soft will get RAW data, in my case Canon RAW data in *.CR2 and my goal is to make GUI in the end with options for user to set values manually or some kind of autotransfer to TIFF
guessing youre a postgraduate? O.o
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

What factors affect your mental health the most right now?

Anxiousness about lockdown easing (59)
4.62%
Uncertainty around my education (196)
15.36%
Uncertainty around my future career prospects (141)
11.05%
Lack of purpose or motivation (181)
14.18%
Lack of support system (eg. teachers, counsellors, delays in care) (57)
4.47%
Impact of lockdown on physical health (72)
5.64%
Loneliness (112)
8.78%
Financial worries (45)
3.53%
Concern about myself or my loves ones getting/having been ill (58)
4.55%
Exposure to negative news/social media (58)
4.55%
Lack of real life entertainment (68)
5.33%
Lack of confidence in making big life decisions (112)
8.78%
Worry about missed opportunities during the pandemic (117)
9.17%

Watched Threads

View All
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise