Sunday, 15 August 2010

python - Stacking images as numpy array -



python - Stacking images as numpy array -

i'm trying utilize for-loop stack 6 different images 1 on top of create 3d stack.i'm new python...and not able figure out. how can create stack , how can access each image in stack later? code this...

image = data.camera() noisyimage = np.zeros(image.shape(0),image.shape(1)) fig = plt.figure(figsize=(12,4)) in range(6): noisyimage = util.random_noise(image,mode='gaussian',seed=i) result = np.dstack(noisyimage,noisyimage) ax = plt.subplot(2,3,i)

try this:

# reshape array (n,m) 1 (n,m,1) no increment in size happens. n1=np.reshape(noisyimage,noisyimage.shape+(1,)) if(i==1): result=n1 else: # concatenate n,m,1 version of array stack using 3rd index (last index) axis. result=np.concatenate(result,n1,axis=n1.ndim-1)

the code below more general implementation (from reply above taken) apply function designed applied single channel channels in image.

def matrixtomultichannel(f,x,*args,**kwargs): nchannels=x.shape[-1] y=np.reshape(x,(x.size/nchannels,nchannels)) in range(0,nchannels): yi=np.reshape(y[:,i],x.shape[:x.ndim-1]) m1=genericf(f,yi,*args, **kwargs) m1=np.reshape(m1,m1.shape+(1,)) if(i==0): fout=m1 else: fout=np.concatenate((fout,m1),axis=m1.ndim-1) homecoming fout

python arrays image numpy

html5 - How to reset the slider value based on checkbox using JavaScript? -



html5 - How to reset the slider value based on checkbox using JavaScript? -

i have range slier & trying reset it's value default if checkbox clicked. can tell how this?

this tried:

html:

<input type="range" id="myrange" max="10000" min="60"> <input type="checkbox" id="lala" onclick="myfunction()"> checkme

javascript:

function myfunction() { document.getelementbyid('myrange').value=60; }

fiddle

you seek phone call undefined function, i´ve edited fiddle http://jsfiddle.net/3kqyaaup/2/ (move js <head>) , works.

<script> function myfunction() { document.getelementbyid('myrange').value=60; } </script> <input type="range" id="myrange" max="10000" min="60"> <input type="checkbox" id="lala" onclick="myfunction()"> checkme

javascript html5 checkbox rangeslider

node.js - "Sandbox" for using multiple instances of a javascript lib -



node.js - "Sandbox" for using multiple instances of a javascript lib -

i'm using js lib, create global variable "av" used everywhere in webapp. want create "sandbox"(not strict sandbox because of no secure concern) utilize multiple different "av"s in 1 webapp.

i wrote wrap browser below , works.

var avcontexts = { app1: null, app2: null } var contextloader = function (appid, appkey) { this.av = null; this.runinthis = function (script) { eval(this.script); this.av.initialize(appid, appkey); } this.loadcontext = function (appid, appkey) { $.ajax({ url: 'js/av.js', datatype: "text", context: }).done(function (data) { this.script = data; this.runinthis.call(this); }).fail(function () { console.log('failed'); }); } this.loadcontext(appid, appkey); } avcontexts.app1 = new contextloader( "[appid]", "[appkey]" ); avcontexts.app2 = new contextloader( "[appid]", "[appkey]" ); // var testobject = avcontexts.app1.av.object.extend("testobject"); var testobject = new testobject(); testobject.save({foo: "bar"}, { success: function (object) { alert("avos cloud works!"); } });

but when move nodejs. error occurred @

this.runinthis.call(this); error: cannot phone call method 'call' of undefined

any idea?

you should cache "this", this:

var me = this;

before utilize $.ajax. , then,

$.ajax().done(function() { me.runinthis.call(); });

if want know reason,

run

console.log(this);

before

this.runinthis.call(this);

you know reason.

javascript node.js

java - Mocking static fields with Mockito -



java - Mocking static fields with Mockito -

i have (it 3rd party library have work design):

classa.conn1.getobjecta().getintvalue()

classa normal class, , within there public static field (conn1). conn1 class have connection , other values used in application (in case objecta).

this value passed parameter in dao mocking. value mocked matchers.anyint() nullpointerexception because conn1 null (not expected int)

i tried things powermockito, whitebox, without success. have done this, same nullpointerexception

mockito.when(classa.conn1.getobjecta()).thenreturn(new objecta(2));

the question is, how can mock objecta or int value of objecta

import static x.y.z.mockito.*; objecta objecta = mock(objecta.class); when(objecta.getintvalue()).thenreturn(1)); conn conn1 = mock(conn.class); when(conn1.getobjecta()).thenreturn(objecta); classa.conn1 = conn1;

java unit-testing mocking mockito

php - Do I need to sanitize POST data when writing to a text file? -



php - Do I need to sanitize POST data when writing to a text file? -

i have post input performing mysql queries with.

i sanitizing post thoroughly before using database queries...no problem there.

now think want start logging in text file users putting in input field ... improve sense users looking for. writing txt file...got covered..no issues

my question is... can safely utilize raw(pre-sanitized) post info string writing text file? see if there funny business beingness posted there test site defenses... injection attempts, etc etc etc. assume fine writing text file ... or wrong , bad practice?

this won't indefinite info gathering on input field, bit see customers looking for.

yes :-)

just little advise, save file outside webroot, nobody can read via web.

php security fopen

php - Opencart Case sensitive search? -



php - Opencart Case sensitive search? -

i'm using opencart version 1.5.6.4 , search results appear case sensitive?

if search "product name" , actual product name "product name" opencart homecoming no results.

is there anyway of ignoring case?

this has been resolved.

i had updated previous version of opencart , imported product info (utf8_bin). since 1.5 database has been switched utf8_general_ci collation text matching in queries no longer case sensitive.

just updated database collation utf8_general_ci. issue resolved.

php search opencart

startswith - Xpath - Selecting attributes using starts-with -



startswith - Xpath - Selecting attributes using starts-with -

i trying write xpath look selects div tags have attribute id start companycalendar. below snippet of html looking at:

<td class="some class" align="center" onclick="calendar_dayclicked(this,'eventcont','event');"> <span class="text"></span> <div id="companycalendar02.21" class="pop calendarclick" style="right: 200px; top: 235px;"></div>

there multiple divs have id companycalendar02.21 each new month in calendar, alter id. example, next month companycalendar02.22. able select of divs equal companycalendar*

i rather new @ using illustration off net seek , xpath look work no avail. help appreciated.

i trying write xpath look selects div tags have attribute id start companycalendar.

the next look perhaps looking for:

//div[starts-with(@id,'companycalendar')]

what does, in plain english, is

return div elements in xml document have attribute id attribute value starts "companycalendar".

xpath startswith