Re: Continuous function, solve an equation and 2D image
- To: mathgroup at smc.vnet.net
- Subject: [mg94347] Re: Continuous function, solve an equation and 2D image
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 10 Dec 2008 05:12:19 -0500 (EST)
- Organization: Uni Leipzig
- References: <ghnfir$nlf$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi, NSolve[ ( i - a ) + ( j - b ) + ( ImageA[[i,j]] - ImageFunction[x][y] ) <= 1, {a,b} ] is *one* inequality for *two* variables {a,b}. There are either no or an infinite number of solutions. x and y are not used in the whole loop construction and it is unclear what you mean. It would be better to describe what you wish to do and for what it is good for. Because the most of us would give you an solution without For[] loops and unsolvable equations. Regards Jens rameshbog at gmail.com wrote: > Hi Mathematica Guru's, > > I am stuck with a problem in evaluating a continous function. I have > two images (A and B), out of which ImageB is interpolated with a > continuous function (ListInterpolation). I want to replace the > intensity values of ImageA only when it finds a solution to the > equation. I have NO idea how to get a solution to this equation. So > please I ask for experts in the field to help me !! > > > Two Images: > ImageA = Import["image1.tiff]; > ImageB = Import["image2.tiff]; > > Interpolation of image B: > ImageFunction = ListInterpolation[Transpose[ImageB]]; > > Length of the image: > Xvalues = Table[a, {a, 1, Length[ImageA]}]; > Yvalues = Table[b, {b, 1, Length[ImageA[[2]]]}]; > > (* Here is the confusion should I use Nsolve or Evaluate for an > equation ?? so that when it is 'true' it should change the intensity > values of ImageA[[i,j]]=0 otherwise ImageA[[i,j]]=1. > > Replacement and Evaluation: > For[i = 1, i = Length[Xvalues], > For[j = 1, j = Length[Yvalues], > > (* Please somebody tell me how to Solve an equation in mathematica > with two different variables(x,y) with a continuous function ) > Test[i,j] = NSolve[ ( i - a ) + ( j - b ) + ( ImageA[[i,j]] - > ImageFunction[x][y] ) <= 1, {a,b} ] > If there is any solution or if it finds any values of 'a' and 'b' for > the above equation then intenstiy values of ImageA[[i,j]] = 0 > otherwise ImageA[[i,j]] = 1]; > j++]; i++]; > > Finally display the image: > ListDensityPlot[ImageA[[All, All]], Mesh -> False]; > > Thanks for your help inadvance !! > > Ram >